一、环境搭建
参考上一章环境
二、项目工程目录
三、主要源程序如下:
registeraccountwindow.cpp
窗口初始化:
void registeraccountWindow::reginit()
{
//去掉?号
this->setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
//更改名称
this->setWindowTitle("register");
//更换左上角图标
this->setWindowIcon(QIcon(":/image/logol.png"));//生成窗口图标
//禁止改变窗口大小 固定大小
this->setFixedSize(408,270);
//设置样式
ui->lineEdit_registeraccount->setStyleSheet("QLineEdit{border-width:1px;border-radius:4px;font-size:12px;color:black;border:1px solid gray;}"
"QLineEdit:hover{border-width:1px;border-radius:4px;font-size:16px;color:black;border:1px solid rgb(204,38,200);}");//边框宽度 边框圆角 字体大小 ... 选中边框颜色
ui->lineEdit_registerpassword->setStyleSheet("QLineEdit{border-width:1px;border-radius:4px;font-size:12px;color:black;border:1px solid gray;}"
"QLineEdit:hover{border-width:1px;border-radius:4px;font-size:12px;color:black;border:1px solid rgb(70,200,50);}");
ui->lineEdit_regosterpassword_ok->setStyleSheet("QLineEdit{border-width:1px;border-radius:4px;font-size:12px;color:black;border:1px solid gray;}"
"QLineEdit:hover{border-width:1px;border-radius:4px;font-size:12px;color:black;border:1px solid rgb(0,18,154);}");
//设置密码框-密文登录
ui->lineEdit_registerpassword->setEchoMode(QLineEdit::Password);
ui->lineEdit_regosterpassword_ok->setEchoMode(QLineEdit::Password);
//密码的隐藏和显示
// 设置样式表(图片为眼睛样式)
ui->checkBox_eye1->setStyleSheet("QCheckBox {spacing: 5px;border: none;background-color: transparent;}"
"QCheckBox::indicator {width: 20px;height: 20px;border: none;image: url(:/image/close_eye.png);}"
"QCheckBox::indicator:checked {image: url(:/image/open_eye.png);}");
ui->checkBox_eye2->setStyleSheet("QCheckBox {spacing: 5px;border: none;background-color: transparent;}"
"QCheckBox::indicator {width: 20px;height: 20px;border: none;image: url(:/image/close_eye.png);}"
"QCheckBox::indicator:checked {image: url(:/image/open_eye.png);}");
//提示信息
ui->lineEdit_registeraccount->setPlaceholderText("请输入设置的用户名 格式10位以内的数字");
ui->lineEdit_registerpassword->setPlaceholderText("请输入设置的密码 格式15位以内的数字") ;
ui->lineEdit_regosterpassword_ok->setPlaceholderText("请再次输入设置的密码 格式15位以内的数字");
ui->lineEdit_checkcode->setPlaceholderText("请输入验证码");
//返回主界面按钮样式 背景透明等
ui->pushButton_back->setStyleSheet("QPushButton {"
" background-color: transparent;"
" border: none;"
" color:rgb(255, 255, 255)"
"}"
"QPushButton:hover{color:rgb(15, 23, 253)}"
"QPushButton:pressed{color:rgb(255, 44, 221)}"
);
//验证码按键样式
ui->pushButton_checkcode->setStyleSheet("QPushButton {"
" background-color: transparent;"
" border: none;"
"}"
"Q