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

运行结果:

思维导图:

相关推荐
Sarvartha4 小时前
final 关键字
java·开发语言
程序员Sunday5 小时前
JavaScript 事件循环面试题,宏任务与微任务怎么执行|Sunday面试指南
开发语言·javascript·面试·校招·事件循环·程序员sunday
Quz5 小时前
QML 动画选择:GIF与Lottie 的区别,以及 Qt 6.8 与 6.11 的 Lottie 实现差异
qt
zhangzeyuaaa6 小时前
Ruby 多线程、GVL(GIL)与 Mutex 完全指南
开发语言·前端·ruby
谢亮_vipxieliang7 小时前
用 PHP 构建轻量级 REST API:从路由到鉴权的完整实践
开发语言·后端·php
思无邪667 小时前
用 AI 做 JS 逆向:从抓包到复现的完整方法论
开发语言·javascript·人工智能
H.莓飛8 小时前
【数据结构】二叉树_OJ题
linux·开发语言·数据结构·算法
零基础1239 小时前
Ubuntu 常用命令汇总
linux·运维·开发语言
外收内放9 小时前
Python基础语法练习题(57-58)
开发语言·python
时间的拾荒人9 小时前
Qt 界面美化实战:QSS 样式表
开发语言·qt·面试