#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()
{
}
运行结果:
思维导图: