网上有做logo的网站吗,监控做斗鱼直播网站,网站建设及制作,营销型网站设计论文1、
完善登录框
点击登录按钮后#xff0c;判断账号#xff08;admin#xff09;和密码#xff08;123456#xff09;是否一致#xff0c;如果匹配失败#xff0c;则弹出错误对话框#xff0c;文本内容“账号密码不匹配#xff0c;是否重新登录”#xff0c;给定两…1、
完善登录框
点击登录按钮后判断账号admin和密码123456是否一致如果匹配失败则弹出错误对话框文本内容“账号密码不匹配是否重新登录”给定两个按钮ok和cancel点击ok后会清除密码框中的内容继续进行登录如果点击cancel按钮则关闭界面。
如果账号和密码匹配则弹出信息对话框给出提示信息为“登录成功”,给出一个按钮ok点击ok后关闭整个登录界面跳转到其他界面
点击取消按钮后弹出问题对话框询问是否确定要退出登录给出两个按钮yes|no,点击yes则直接关闭整个登录界面如果点击no则进行进行登录
要求消息对话框对象版和静态成员函数版至少各实现一个
mianwindow.h
QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACEclass MainWindow : public QMainWindow
{Q_OBJECTpublic:MainWindow(QWidget *parent nullptr);~MainWindow();signals:void jump(); //自定义跳转信号函数private slots:void on_pushButton_clicked();void on_pushButton_2_clicked();private:Ui::MainWindow *ui;Second *s1; //定义另一个界面的指针
};
#endif // MAINWINDOW_H
second.h
#ifndef SECOND_H
#define SECOND_H#include QDialognamespace Ui {
class Second;
}class Second : public QDialog
{Q_OBJECTpublic:explicit Second(QWidget *parent nullptr);~Second();public slots:void jump_slot(); //接收跳转信号的槽函数private:Ui::Second *ui;
};#endif // SECOND_H
mianwindow.cpp
#include mainwindow.h
#include ui_mainwindow.hMainWindow::MainWindow(QWidget *parent): QMainWindow(parent), ui(new Ui::MainWindow)
{ui-setupUi(this);ui-label-setPixmap(QPixmap(D:\\QTtupian\\jimoaqing.gif));ui-label-setScaledContents(true);ui-label_2-setPixmap(QPixmap(D:\\QTtupian\\zhanghao.jpg));ui-label_2-setScaledContents(true);ui-label_3-setPixmap(QPixmap(D:\\QTtupian\\mima.jpg));ui-label_3-setScaledContents(true);s1 new Second; //给另一个界面实例化空间//将当前界面的信号与s1界面的槽函数进行连接connect(this,MainWindow::jump, s1, Second::jump_slot);
}MainWindow::~MainWindow()
{delete ui;
}void MainWindow::on_pushButton_clicked()
{if(ui-lineEdit-text()adminui-lineEdit_2-text()123456){//信息对话框QMessageBox box(QMessageBox::Question,信息对话框,登录成功,QMessageBox::Ok,this);box.setDefaultButton(QMessageBox::Ok); //默认到ok上int ret box.exec(); //运行对话框if(ret QMessageBox::Ok){emit jump(); //发送跳转信息this-hide(); //将当前界面隐藏}}else{//错误对话框QMessageBox box(QMessageBox::Question,错误对话框,账号密码不匹配是否重新登录,QMessageBox::Ok|QMessageBox::Cancel,this);box.setDefaultButton(QMessageBox::Ok); //默认到ok上int ret box.exec(); //运行对话框switch(ret){case QMessageBox::Ok:ui-lineEdit-clear(); //清楚账号密码内容ui-lineEdit_2-clear();break;case QMessageBox::Cancel://retbox.close();break;}}}void MainWindow::on_pushButton_2_clicked()
{//问题对话框int ret QMessageBox::question(this,问题对话框,是否确定要退出登录,QMessageBox::Yes|QMessageBox::No,QMessageBox::No);switch(ret){case QMessageBox::Yes:this-close(); //关闭窗口break;case QMessageBox::No:break;}
}
second.cpp
#include second.h
#include ui_second.hSecond::Second(QWidget *parent) :QDialog(parent),ui(new Ui::Second)
{ui-setupUi(this);
}Second::~Second()
{delete ui;
}//接收跳转信号对应的槽函数
void Second::jump_slot()
{this-show(); //将自己界面进行展示
}
主函数
#include mainwindow.h#include QApplicationint main(int argc, char *argv[])
{QApplication a(argc, argv);MainWindow w;w.show();return a.exec();
}
2、思维导图