购物网站有哪些平台,网站建设必须要做404,网站开源程序,成都网站建设1381 思维导图
https://lingjun.life/wiki/EmbeddedNote/20QT
2 完善登录界面
完善对话框#xff0c;点击登录对话框#xff0c;如果账号和密码匹配#xff0c;则弹出信息对话框#xff0c;给出提示”登录成功“#xff0c;提供一个Ok按钮#xff0c;用户点击Ok后…1 思维导图
https://lingjun.life/wiki/EmbeddedNote/20QT
2 完善登录界面
完善对话框点击登录对话框如果账号和密码匹配则弹出信息对话框给出提示”登录成功“提供一个Ok按钮用户点击Ok后关闭登录界面跳转到其他界面
如果账号和密码不匹配弹出错误对话框给出信息”账号和密码不匹配是否重新登录“,并提供两个按钮Yes|No用户点击Yes后清除密码框中的内容继续让用户进行登录如果用户点击No按钮则直接关闭登录界面
如果用户点击取消按钮则弹出一个问题对话框给出信息”您是否确定要退出登录“并给出两个按钮Yes|No用户迪纳基Yes后关闭登录界面用户点击No后关闭对话框继续执行登录功能
要求基于属性版和基于静态成员函数版至少各用一个
#include mywidget.h
#include QPainterPath
#include aerowidget.hMyWidget::MyWidget(QWidget *parent): QWidget(parent)
{// 窗口设置setWindowTitle(登录); // 设置窗口标题setWindowFlag(Qt::FramelessWindowHint); // 设置窗口无边框resize(400,560); // 设置窗口大小setFixedSize(400,560); // 固定窗口大小// 设置窗口图标setWindowIcon(QIcon(C:\\Users\\lingj\\Desktop\\QT\\test1_1\\favicon.ico));// 创建并设置 QLabelQLabel *l1 new QLabel(this);l1-setText(hello world);l1-setParent(this);l1-resize(320,100);l1-move(40,40);l1-setPixmap(QPixmap(:/pic/hello.png)); // 设置图片l1-setScaledContents(true); // 图片自适应大小// 创建 AeroWidgetAeroWidget aw(this);aw.setAlpha(4);// 设置窗口圆角矩形遮罩aw.setMask(createMask());// 加入文本输入框username new QLineEdit(this);username-move(40,210);username-resize(320,50);username-setStyleSheet(background-color:rgb(255,255,255);border-radius:10px);username-setAlignment(Qt::AlignCenter);username-setPlaceholderText(账号\\电话\\邮箱);passwd new QLineEdit(this);passwd-move(40,280);passwd-resize(320,50);passwd-setStyleSheet(background-color:rgb(255,255,255);border-radius:10px);passwd-setAlignment(Qt::AlignCenter);passwd-setPlaceholderText(密码);passwd-setEchoMode(QLineEdit::Password); // 设置密码模式// 创建登录按钮QPushButton *p1 new QPushButton(登录,this);p1-move(40,400);p1-resize(320,50);p1-setStyleSheet(background-color:rgb(255,255,255);border-radius:10px);connect(p1, QPushButton::clicked, this, MyWidget::on_login_clicked); // 连接登录按钮的点击事件// 创建关闭按钮QPushButton *closeButton new QPushButton(×, this); // Close buttoncloseButton-setFixedSize(20, 20);closeButton-move(width() - closeButton-width() - 5, 5);closeButton-setStyleSheet(background-color:transparent;color:white;font-size:16px;);connect(closeButton,SIGNAL(clicked()),this,SLOT(on_close_clicked())); // 连接关闭按钮的点击事件// 创建最小化按钮QPushButton *minimizeButton new QPushButton(-, this); // Minimize buttonminimizeButton-setFixedSize(20, 20);minimizeButton-move(width() - minimizeButton-width() - closeButton-width() - 5, 5);minimizeButton-setStyleSheet(background-color:transparent;color:white;font-size:16px;);connect(minimizeButton, QPushButton::clicked, this, QWidget::showMinimized); // 连接最小化按钮的点击事件// 设置鼠标追踪setMouseTracking(true);
}MyWidget::~MyWidget()
{}
void MyWidget::on_close_clicked()
{int res QMessageBox::question(this,提示,您是否要退出登录,QMessageBox::Yes | QMessageBox::No);if(res QMessageBox::Yes){close();}
}
void MyWidget::on_login_clicked()
{qDebug() 登录中…… ;if(username-text()admin passwd-text() 123456){qDebug() 登录成功;int res QMessageBox::information(this,提示,登陆成功,QMessageBox::Ok);if(res QMessageBox::Ok){close();emit my_jump();}}else{int res QMessageBox::information(this,提示,账号和密码不匹配,QMessageBox::Yes | QMessageBox::No);if(res QMessageBox::Yes){username-clear();passwd-clear();}else{close();}qDebug() 登录失败用户名或密码错误;}
}// 创建窗口遮罩的函数
QRegion MyWidget::createMask() const
{int radius 18; // 圆角半径QSize size this-size();QRegion region;QPainterPath path;path.addRoundedRect(QRectF(QPointF(0, 0), size), radius, radius); // 创建圆角矩形路径region QRegion(path.toFillPolygon().toPolygon()); // 转换为多边形区域return region;
}// 重写鼠标按下事件
void MyWidget::mousePressEvent(QMouseEvent *event)
{if (event-button() Qt::LeftButton) {// 保存鼠标按下时的位置和窗口位置m_dragPos event-globalPos() - frameGeometry().topLeft();event-accept();}
}// 重写鼠标移动事件
void MyWidget::mouseMoveEvent(QMouseEvent *event)
{if (event-buttons() Qt::LeftButton) {// 移动窗口到鼠标位置move(event-globalPos() - m_dragPos);event-accept();}
}
main.cpp
#include mywidget.h
#include aerowidget.h
#include sec.h#include QApplicationint main(int argc, char *argv[])
{QApplication a(argc, argv);MyWidget w;sec s;w.show();QObject::connect(w,MyWidget::my_jump, s, sec::my_jump_slot);return a.exec();
}