1.给工程文件加入注释
2.制作登入界面
- #include "mainwindow.h"
-
- MainWindow::MainWindow(QWidget *parent)
- : QMainWindow(parent)
- {
- this->setFixedSize(600,400);//设置固定尺寸
- this->setWindowIcon(QIcon("C:/Users/WS/Pictures/Saved Pictures/yh.png"));//改变左上角图标的位
- this->setWindowTitle("易碗浆糊");//窗口的名字
- //this->setStyleSheet("background-color:pink;");//背景颜色
- QLabel *lab1=new QLabel(this);//实例化一个标签
- lab1->resize(600,170);//重新设置尺寸
- lab1->setStyleSheet("background-color:yellow");
- lab1->setAlignment(Qt::AlignCenter);
- lab1->setPixmap(QPixmap("C:/Users/WS/Pictures/Saved Pictures/fjh.png"));
- lab1->setScaledContents(true);
- this->setStyleSheet("background-color:white;");//背景颜色
-
- //用户名框
- QLineEdit *edit1=new QLineEdit(this);
- edit1->resize(230,45);
- edit1->move(lab1->x()+200,lab1->y()+200);
- edit1->setPlaceholderText("用户名");//设置占位文本
- //密码框
- QLineEdit *edit2=new QLineEdit(this);
- edit2->resize(230,45);
- edit2->move(edit1->x(),edit1->y()+75);
- edit2->setPlaceholderText("密码");//设置占位文本
- edit2->setEchoMode(QLineEdit::Password);//设置回显模式
- //实例化一个标签
- QLabel *lab2=new QLabel(this);
- lab2->resize(45,45);//重新设置尺寸
- lab2->setAlignment(Qt::AlignCenter);
- lab2->setPixmap(QPixmap("C:/Users/WS/Pictures/wxn.png"));
- lab2->setScaledContents(true);
- lab2->move(lab1->x()+140,lab1->y()+200);
- //实例化一个标签
- QLabel *lab3=new QLabel(this);
- lab3->resize(45,45);//重新设置尺寸
- lab3->setAlignment(Qt::AlignCenter);
- lab3->setPixmap(QPixmap("C:/Users/WS/Pictures/wxnnn.png"));
- lab3->setScaledContents(true);
- lab3->move(lab1->x()+140,lab1->y()+275);
- //实例化一个按钮
- QPushButton *btn1=new QPushButton(this);
- btn1->setText("登录");
- btn1->resize(70,40);
- btn1->move(lab3->x()+80,lab3->y()+70);
- btn1->setStyleSheet("background-color:white;border-radius:10px;");//设置组件背景色
- btn1->setIcon(QIcon("C:/Users/WS/Pictures/wq.png"));
- //实例化一个按钮
- QPushButton *btn2=new QPushButton(this);
- btn2->setText("退出");
- btn2->resize(70,40);
- btn2->move(btn1->x()+130,btn1->y());
- btn2->setStyleSheet("background-color:white;border-radius:10px;");//设置组件背景色
- btn2->setIcon(QIcon("C:/Users/WS/Pictures/wq2.png"));
-
-
- }
-
- MainWindow::~MainWindow()
- {
- }
-