Qt图形设计

cpp 复制代码
#include "mywidget.h"

MyWidget::MyWidget(QWidget *parent)
    : QWidget(parent)
{
    //===============窗口相关设置===========
    //设置窗口标题
    this->setWindowTitle("王者荣耀");
    //设置窗口图标
    this->setWindowIcon(QIcon("C:\\Users\\28033\\Pictures\\Saved Pictures\\pictrue\\wzry.png"));

    //设置窗口大小
    this->resize(1200,700);
    //固定窗口大小
    this->setFixedSize(1200,700);

    //==============标签相关设置============
    QLabel *lab1 = new QLabel(this);
    lab1->resize(1200,700);
    //设置背景颜色
    lab1->setStyleSheet("background-color:pink");
    //设置动图
    QMovie *mv = new QMovie("C:\\Users\\28033\\Pictures\\Saved Pictures\\wzry.gif");
    //将动图放入lab1中
    lab1->setMovie(mv);
    //将动图设置为自动适应lab
    lab1->setScaledContents(true);
    mv->start();

    QLabel *lab2 = new QLabel(this);
    lab2->resize(50,75);
    //lab2->setStyleSheet("background-color:purple");
    lab2->move(160,595);
    //设置图像
    lab2->setPixmap(QPixmap("C:/Users/28033/Pictures/Saved Pictures/pictrue/yk.png"));
    //将图片自动适应lab2
    lab2->setScaledContents(true);

    QLabel *lab3 = new QLabel(this);
    lab3->resize(50,75);
    //lab3->setStyleSheet("background-color:green");
    lab3->move(470,595);
    lab3->setPixmap(QPixmap("C:\\Users\\28033\\Pictures\\Saved Pictures\\pictrue\\weixin.jpg"));
    lab3->setScaledContents(true);


    QLabel *lab4 = new QLabel(this);
    lab4->resize(50,75);
    //lab3->setStyleSheet("background-color:green");
    lab4->move(775,595);
    lab4->setPixmap(QPixmap("C:\\Users\\28033\\Pictures\\Saved Pictures\\pictrue\\qq.png"));
    lab4->setScaledContents(true);

//    //==============行编辑器相关设置==========
//    QLineEdit *edit1 = new QLineEdit(this);
//    //设置行编辑器的大小
//    edit1->resize(380,120);
//    //移动行编辑器
//    edit1->move(380,0);





    //==============按钮相关设置=============
    QPushButton *btn1 = new QPushButton(this);
    //移动按钮
    btn1->move(200,595);
    //设置按钮大小
    btn1->resize(240,75);
    //设置按钮的标题
    btn1->setText("游客登录");
    //设置背景颜色和弧度
    btn1->setStyleSheet("background-color:rgb(92,85,227);border-radius:30px");

    QPushButton *btn2 = new QPushButton(this);
    btn2->move(512,595);
    btn2->resize(225,75);
    btn2->setText("与微信好友玩");
    btn2->setStyleSheet("background-color:green;border-radius:30px");

    QPushButton *btn3 = new QPushButton(this);
    btn3->move(815,595);
    btn3->resize(235,75);
    btn3->setText("与QQ好友玩");
    btn3->setStyleSheet("background-color:skyblue;border-radius:30px");



}

MyWidget::~MyWidget()
{
}

运行结果:

思维导图:

相关推荐
用户805533698034 天前
不止三件套:QObject 属性系统全关键字与运行时反射!
c++·qt
xcyxiner4 天前
DicomViewer (vcpkg Windows和ubuntu编译)7
qt
Quz9 天前
QML Hello World 入门示例
qt
xcyxiner12 天前
DicomViewer (dcmtk读取dcm文件)5
qt
xcyxiner13 天前
DicomViewer (后台线程处理文件)4
qt
xcyxiner13 天前
DicomViewer (添加模型类)3
qt
xcyxiner14 天前
DicomViewer (目录调整) 2
qt
xcyxiner14 天前
dcmtk vtk vtk-dicom(gdcm) 编译(debug) v2
qt
LDR00616 天前
Type-C 快充全面升级!LDR6601 赋能个人护理便携电机,重塑剃须刀 / 理发器新体验
c语言·开发语言
雪碧聊技术16 天前
Tree.js是什么?一文讲透
开发语言·javascript·ecmascript