窗口实现代码
#include "widget.h"
Widget::Widget(QWidget *parent)
: QWidget(parent)
{
this->setFixedSize(538, 373);
this->setWindowIcon(QIcon("G:\\QT_Icon\\windos_icon2.png"));
this->setWindowTitle("My QQ");
QLabel *lab1 = new QLabel(this);
QLabel *lab2 = new QLabel(this);
lab1->resize(538, 153);
lab1->setStyleSheet("background-color:skyblue");
lab2->setPixmap(QPixmap("G:\\QT_Icon\\windos_icon2.png"));
lab2->resize(80, 80);
lab2->setScaledContents(true);
lab2->move(229, 53);
QLineEdit *ledit1 = new QLineEdit(this);
QLineEdit *ledit2 = new QLineEdit(this);
ledit1->resize(260, 40);
ledit2->resize(260, 40);
ledit1->move(159, lab2->y()+120);
ledit2->move(ledit1->x(), ledit1->y()+60);
ledit1->setPlaceholderText("QQ账号/手机号/邮箱");
ledit2->setEchoMode(QLineEdit::Password);
ledit1->setMaxLength(16);
ledit2->setMaxLength(16);
QLabel *lab3 = new QLabel(this);
QLabel *lab4 = new QLabel(this);
lab3->resize(30, 30);
lab3->setPixmap(QPixmap("G:\\QT_Icon\\windos_icon1.png"));
lab3->setScaledContents(true);
lab3->move(ledit1->x()-40, ledit1->y()+5);
lab4->setPixmap(QPixmap("G:\\QT_Icon\\password.png"));
lab4->setScaledContents(true);
lab4->resize(30, 30);
lab4->move(ledit2->x()-40, ledit2->y()+5);
QPushButton *btn1 = new QPushButton("登录" ,this);
btn1->resize(300, 40);
btn1->setStyleSheet("background-color:rgb(8,189,253);");
btn1->move(lab3->x(), lab4->y()+60);
}
Widget::~Widget()
{
}
效果图