实现登录窗口
#include "loginwindow.h"
LoginWindow::LoginWindow(QWidget *parent)
: QWidget(parent)
{
//设置窗口标题和图标
this->setWindowTitle("ChatWe");
this->setWindowIcon(QIcon("D:\\learn\\QT\\day1\\work\\login.png"));
//设置窗口的大小 固定
this->setFixedSize(800,500);
//设置上1/2处label图标放置背景图
QLabel *labelpic = new QLabel(this);
//一半大小
labelpic->resize(800,250);
//放入图片
labelpic->setPixmap(QPixmap("D:\\learn\\QT\\day1\\work\\bg.png"));
/***********************************************************************/
//账号图标
QLabel *labelaccount = new QLabel(this);
labelaccount->resize(50,50);
//移动位置
labelaccount->move(150,280);
labelaccount->setPixmap(QPixmap("D:\\learn\\QT\\day1\\work\\account.png"));
labelaccount->setScaledContents(true);
//账号编辑框
QLineEdit *editaccount = new QLineEdit(this);
editaccount->setPlaceholderText("请输入账号");
editaccount->setAlignment(Qt::AlignCenter);
editaccount->resize(300,50);
editaccount->setMaxLength(20);
editaccount->move(labelaccount->x()+100,labelaccount->y());
//密码图标
QLabel *labelpwd = new QLabel(this);
labelpwd->resize(50,50);
//移动位置
labelpwd->move(labelaccount->x(),labelaccount->y()+80);
labelpwd->setPixmap(QPixmap("D:\\learn\\QT\\day1\\work\\psw.png"));
labelpwd->setScaledContents(true);
//密码编辑框
QLineEdit *editpwd = new QLineEdit(this);
editpwd->setPlaceholderText("请输入密码");
editpwd->setEchoMode(QLineEdit::Password);
editpwd->setAlignment(Qt::AlignCenter);
editpwd->resize(300,50);
editpwd->setMaxLength(20);
editpwd->move(editaccount->x(),editaccount->y()+80);
//登录按钮
QPushButton *login = new QPushButton(QIcon("D:\\learn\\QT\\day1\\work\\accept.png"),"登录",this);
login->move(editpwd->x()+10,editpwd->y()+80);
//退出按钮
QPushButton *exit = new QPushButton(QIcon("D:\\learn\\QT\\day1\\work\\reject.png"),"登录",this);
exit->move(editpwd->x()+180,editpwd->y()+80);
}
LoginWindow::~LoginWindow()
{
}

- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
效果
