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);//图片1lab1->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);//图片2QLabel *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);//图片3QLabel *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()
{
}
运行截图
思维导图