Qt代码
#include "mywnd.h"
//构造函数的定义
mywnd::mywnd(QWidget *parent)
: QWidget(parent) //显性调用父类的有参构造完成对子类从父类继承下来成员的初始化工作
{
//窗口设置
this->resize(QSize(500, 433));
this->setWindowTitle("Widget");
this->setWindowIcon(QIcon("G:\\study\\Qt\\C++&Qt\\9.15\\work\\icon\\wodepeizhenshi.png"));
QLabel *lab1 = new QLabel(this);
//图片1
lab1->resize(QSize(500, 200));
lab1->setPixmap(QPixmap("G:\\study\\Qt\\C++&Qt\\9.15\\work\\icon\\logo.png"));
lab1->move(QPoint(0, 0));
lab1->setScaledContents(true);
//图片2
QLabel *lab2 = new QLabel(this);
lab2->resize(QSize(50, 50));
lab2->setPixmap(QPixmap("G:\\study\\Qt\\C++&Qt\\9.15\\work\\icon\\userName.jpg"));
lab2->move(QPoint(60, 230));
lab2->setScaledContents(true);
//图片3
QLabel *lab3 = new QLabel(this);
lab3->resize(QSize(50, 50));
lab3->setPixmap(QPixmap("G:\\study\\Qt\\C++&Qt\\9.15\\work\\icon\\passwd.jpg"));
lab3->move(QPoint(60, 310));
lab3->setScaledContents(true);
//账号行编辑器
QLineEdit *lin1 = new QLineEdit(this);
lin1->resize(250, 50);
lin1->move(QPoint(150, 230));
//密码行编辑器
QLineEdit *lin2 = new QLineEdit(this);
lin2->resize(250, 50);
lin2->move(QPoint(150, 310));
lin2->setEchoMode(QLineEdit::Password);
//登录按钮
QPushButton *btn1 = new QPushButton(QIcon("G:\\study\\Qt\\C++&Qt\\9.15\\work\\icon\\login.png") ,"登录", this);
btn1->resize(80, 50);
btn1->move(QPoint(130, 370));
//取消按钮
QPushButton *btn2 = new QPushButton(QIcon("G:\\study\\Qt\\C++&Qt\\9.15\\work\\icon\\cancel.png") ,"取消", this);
btn2->resize(80, 50);
btn2->move(QPoint(290, 370));
}
mywnd::~mywnd()
{
}
运行截图
思维导图