登录框设置
#include "zuoye.h"
#include "ui_zuoye.h"Zuoye::Zuoye(QWidget *parent): QWidget(parent), ui(new Ui::Zuoye)
{ui->setupUi(this);//界面this->resize(540,420); //设置尺寸this->setFixedSize(540,420);//固定尺寸this->setStyleSheet("background-color:white;");//背景颜色this->setWindowOpacity(0.95);//透明度this->setWindowIcon(QIcon("E:\\ _Xmind_PDF\\QT笔记\\icon\\qq.png"));//标题栏图标this->setWindowTitle("马❤哥❤快❤聊");//标题栏名字//按钮 1-登录 2-取消 QPushbuttonbtn_enter = new QPushButton;//构造按钮btn_enter->setParent(this);//设置父组件btn_enter->setText("登录");//设置文本内容btn_enter->resize(75,40);//设置按钮大小btn_enter->setStyleSheet("background-color:skyblue;border-radius:10px");//设置样式,背景色,btn_enter->setIcon(QIcon("E:\\ _Xmind_PDF\\QT笔记\\icon\\denglu_1.png"));//设置按钮图标btn_enter->setEnabled(true);//设置可用状态btn_enter->move(170,320);//移动组件btn_cancel = new QPushButton;//构造按钮btn_cancel->setParent(this);//设置父组件btn_cancel->setText("取消");//设置文本内容btn_cancel->resize(75,40);//设置按钮大小btn_cancel->setStyleSheet("background-color:skyblue;border-radius:10px");//设置样式,背景色,btn_cancel->setIcon(QIcon("E:\\_Xmind_PDF\\QT笔记\\icon\\quxiao.png"));//设置按钮图标btn_cancel->setEnabled(true);//设置可用状态btn_cancel->move(290,320);//移动组件//设置标签 1-账户 2-密码 3-logo labellab_id = new QLabel;//构造标签lab_id->setParent(this);//设置父组件lab_id->resize(40,40);//设置尺寸lab_id->setPixmap(QPixmap("E:\\ _Xmind_PDF\\QT笔记\\icon\\denglu.png"));//设置图标lab_id->setScaledContents(true);//设置内容自适应lab_id->move(100,170);//移动lab_pwd = new QLabel;//构造标签lab_pwd->setParent(this);//设置父组件lab_pwd->resize(40,40);//设置尺寸lab_pwd->setPixmap(QPixmap("E:\\_Xmind_PDF\\QT笔记\\icon\\denglumima.png"));//设置图标lab_pwd->setScaledContents(true);//设置内容自适应lab_pwd->move(100,250);//移动lab_logo = new QLabel;//构造标签lab_logo->setParent(this);//设置父组件lab_logo->resize(120,120);//设置尺寸lab_logo->setPixmap(QPixmap("E:\\Xmind_PDF\\QT笔记\\icon\\qq.png"));//设置图标lab_logo->setScaledContents(true);//设置内容自适应lab_logo->move(205,20);//移动//设置行编辑器 1-账号, 2-密码edit_id = new QLineEdit;//构造edit_id->setParent(this);//设置父组件edit_id->resize(250,50);//重新设置尺寸edit_id->setStyleSheet("background-color:red;");//设置颜色//edit_id->setPlaceholderText("账号");//设置占位符edit_id->setEchoMode(QLineEdit::Normal);//设置密文模式edit_id->setStyleSheet("border:none;""border-bottom:2px solid blue;");//更改样式表edit_id->move(180,160);//移动QFont font;font.setPointSize(12); // 设置字体大小为12edit_id->setFont(font);// 将字体应用于行编辑器edit_pwd = new QLineEdit;//构造edit_pwd->setParent(this);//设置父组件edit_pwd->resize(250,50);//重新设置尺寸edit_pwd->setStyleSheet("background-color:red;");//设置颜色//edit_pwd->setPlaceholderText("密码");//设置占位符edit_pwd->setEchoMode(QLineEdit::Password);//设置密文模式edit_pwd->setStyleSheet("border:none;""border-bottom:2px solid blue;");//更改样式表edit_pwd->move(180,240);//移动edit_pwd->setFont(font);// 设置字体大小为12}Zuoye::~Zuoye()
{delete ui;
}
头文件
#ifndef ZUOYE_H
#define ZUOYE_H#include <QWidget>
#include <QDebug>
#include <QIcon>
#include <QPushButton>
#include <QLineEdit>
#include <QLabel>QT_BEGIN_NAMESPACE
namespace Ui { class Zuoye; }
QT_END_NAMESPACEclass Zuoye : public QWidget
{Q_OBJECTQPushButton *btn_enter; //登录按钮QPushButton *btn_cancel; //取消按钮QLabel *lab_id; //账号QLabel *lab_pwd; //密码QLabel *lab_logo; //logoQLineEdit *edit_id;//行编辑器账号QLineEdit *edit_pwd;//行编辑器密码public:Zuoye(QWidget *parent = nullptr);~Zuoye();private:Ui::Zuoye *ui;
};
#endif // ZUOYE_H