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

运行结果:

思维导图:

相关推荐
郑州光合科技余经理3 天前
代码展示:PHP搭建海外版外卖系统源码解析
java·开发语言·前端·后端·系统架构·uni-app·php
feifeigo1233 天前
matlab画图工具
开发语言·matlab
dustcell.3 天前
haproxy七层代理
java·开发语言·前端
norlan_jame3 天前
C-PHY与D-PHY差异
c语言·开发语言
多恩Stone3 天前
【C++入门扫盲1】C++ 与 Python:类型、编译器/解释器与 CPU 的关系
开发语言·c++·人工智能·python·算法·3d·aigc
QQ4022054963 天前
Python+django+vue3预制菜半成品配菜平台
开发语言·python·django
遥遥江上月3 天前
Node.js + Stagehand + Python 部署
开发语言·python·node.js
m0_531237173 天前
C语言-数组练习进阶
c语言·开发语言·算法
Railshiqian3 天前
给android源码下的模拟器添加两个后排屏的修改
android·开发语言·javascript
雪人不是菜鸡3 天前
简单工厂模式
开发语言·算法·c#