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

运行结果:

思维导图:

相关推荐
Bl_a_ck4 分钟前
【React】Craco 简介
开发语言·前端·react.js·typescript·前端框架
编程有点难9 分钟前
Python训练打卡Day23
开发语言·python
程序员爱钓鱼10 分钟前
跳转语句:break、continue、goto -《Go语言实战指南》
开发语言·后端·golang·go1.19
hardStudy_h17 分钟前
C程序的存储空间分配
c语言·开发语言
橙子1991101618 分钟前
Kotlin 中的 Unit 类型的作用以及 Java 中 Void 的区别
java·开发语言·kotlin
yours_Gabriel25 分钟前
【登录认证】JWT令牌
java·开发语言·redis
lyw20561939 分钟前
微服务八股(自用)
java·开发语言
dot to one39 分钟前
Qt 中 QWidget涉及的常用核心属性介绍
开发语言·c++·qt
液态不合群1 小时前
理解 C# 中的各类指针
java·开发语言·c#
橙子199110161 小时前
Kotlin 中的作用域函数
android·开发语言·kotlin