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()
{
}

运行结果:

思维导图:

相关推荐
云知谷1 分钟前
【HTML】网络数据是如何渲染成HTML网页页面显示的
开发语言·网络·计算机网络·html
lly2024061 小时前
SQL ROUND() 函数详解
开发语言
大宝剑1701 小时前
python环境安装
开发语言·python
lly2024061 小时前
CSS3 多媒体查询
开发语言
天***88962 小时前
js封装一个双精度算法实现
开发语言·前端·javascript
.小小陈.2 小时前
数据结构2:单链表
c语言·开发语言·数据结构·笔记·学习方法
Camel卡蒙2 小时前
数据结构——二叉搜索树Binary Search Tree(介绍、Java实现增删查改、中序遍历等)
java·开发语言·数据结构
Algebraaaaa2 小时前
什么是前端、后端与全栈开发,Qt属于什么?
开发语言·前端·qt
立志成为大牛的小牛2 小时前
数据结构——二十三、并查集的终极优化(王道408)
开发语言·数据结构·笔记·学习·程序人生·考研