• day0918


    1. #include
    2. #include
    3. QT_BEGIN_NAMESPACE
    4. namespace Ui { class hqyj; }
    5. QT_END_NAMESPACE
    6. class hqyj : public QWidget
    7. {
    8. Q_OBJECT
    9. public:
    10. hqyj(QWidget *parent = nullptr);
    11. ~hqyj();
    12. signals:
    13. void jumpToLogin();
    14. public slots:
    15. void loginBtn_slot();
    16. void cancelBtn_slot();
    17. private:
    18. Ui::hqyj *ui;
    19. QLabel*lab1 = new QLabel(this);
    20. QLineEdit *edit1 = new QLineEdit(this);
    21. QLineEdit *edit2 = new QLineEdit(this);
    22. QLabel *lab2 = new QLabel(this);
    23. QLabel *lab3 = new QLabel(this);
    24. QPushButton *btn1 = new QPushButton("登录",this);
    25. QPushButton *btn2 = new QPushButton("取消",this);
    26. login *l1 = new login;;
    27. };
    28. #endif // HQYJ_H
    1. #ifndef LOGIN_H
    2. #define LOGIN_H
    3. #include
    4. namespace Ui {
    5. class login;
    6. }
    7. class login : public QDialog
    8. {
    9. Q_OBJECT
    10. public slots:
    11. void jumpToLogin_slot();
    12. public:
    13. explicit login(QWidget *parent = nullptr);
    14. ~login();
    15. private:
    16. Ui::login *ui;
    17. };
    18. #endif // LOGIN_H
    1. #include "hqyj.h"
    2. #include
    3. #include
    4. #include "ui_hqyj.h"
    5. hqyj::hqyj(QWidget *parent)
    6. : QWidget(parent)
    7. , ui(new Ui::hqyj)
    8. {
    9. ui->setupUi(this);
    10. this->setWindowTitle("Widget");
    11. this->setWindowIcon(QIcon("D:\\230906C++&Qt\\icon\\wodepeizhenshi.png"));
    12. this->setFixedSize(QSize(400,300));
    13. lab1->resize(QSize(400,133));
    14. lab1->move(0,0);
    15. lab1->setPixmap(QPixmap("D:\\230906C++&Qt\\icon\\logo.png"));
    16. lab1->setScaledContents(true);
    17. edit1->resize(QSize(240,40));
    18. edit1->move(110,150);
    19. edit1->setPlaceholderText("账号");
    20. edit2->resize(QSize(240,40));
    21. edit2->move(edit1->x(),edit1->y()+55);
    22. edit2->setPlaceholderText("密码");
    23. edit2->setEchoMode(QLineEdit::Password);
    24. lab2->resize(50,40);
    25. lab2->setPixmap(QPixmap("D:\\230906C++&Qt\\icon\\userName.jpg"));
    26. lab2->setScaledContents(true);
    27. lab2->move(edit1->x()-60,edit1->y());
    28. lab3->resize(50,40);
    29. lab3->setPixmap(QPixmap("D:\\230906C++&Qt\\icon\\passwd.jpg"));
    30. lab3->setScaledContents(true);
    31. lab3->move(edit2->x()-60,edit2->y());
    32. btn1->resize(QSize(60,30));
    33. btn2->resize(btn1->size());
    34. btn1->move(120,edit2->y()+55);
    35. btn2->move(btn1->x()+120,edit2->y()+55);
    36. btn1->setIcon(QIcon("D:\\230906C++&Qt\\icon\\login.png"));
    37. btn2->setIcon(QIcon("D:\\230906C++&Qt\\icon\\cancel.png"));
    38. connect(btn1,&QPushButton::clicked,this,&hqyj::loginBtn_slot);
    39. connect(btn2,&QPushButton::clicked,this,&hqyj::cancelBtn_slot);
    40. connect(this,&hqyj::jumpToLogin,l1,&login::jumpToLogin_slot);
    41. }
    42. hqyj::~hqyj()
    43. {
    44. delete ui;
    45. }
    46. void hqyj::loginBtn_slot()
    47. {
    48. if(edit1->text()==QString("damin")&&edit2->text()==QString("123456"))
    49. {
    50. QMessageBox box(QMessageBox::Information,
    51. "登录成功",
    52. "登录成功",
    53. QMessageBox::Ok,
    54. this);
    55. box.exec();
    56. emit this->jumpToLogin();
    57. this->close();
    58. }else
    59. {
    60. QMessageBox box(QMessageBox::Critical,
    61. "错误",
    62. "账号密码不匹配,是否重新登录",
    63. QMessageBox::Ok|QMessageBox::Cancel,
    64. this);
    65. box.setDefaultButton(QMessageBox::Ok);
    66. int ret = box.exec();
    67. if(QMessageBox::Ok==ret)
    68. {
    69. edit2->clear();
    70. }else
    71. this->close();
    72. }
    73. }
    74. void hqyj::cancelBtn_slot()
    75. {
    76. int ret = QMessageBox::question(this,
    77. "请问",
    78. "是否确认要退出",
    79. QMessageBox::Yes|QMessageBox::No,
    80. QMessageBox::No);
    81. switch(ret)
    82. {
    83. case QMessageBox::Yes:
    84. this->close();
    85. break;
    86. case QMessageBox::No:
    87. break;
    88. default:
    89. break;
    90. }
    91. }
    1. #include "login.h"
    2. #include "ui_login.h"
    3. login::login(QWidget *parent) :
    4. QDialog(parent),
    5. ui(new Ui::login)
    6. {
    7. ui->setupUi(this);
    8. }
    9. login::~login()
    10. {
    11. delete ui;
    12. }
    13. void login::jumpToLogin_slot()
    14. {
    15. this->show();
    16. }

  • 相关阅读:
    【红日靶场】vulnstack3-完整渗透过程
    龙测票选,5本最受欢迎的软件测试书籍
    内外网结合的多服务发布架构
    Ubuntu20.04.1编译qt6.5.3版mysql驱动
    【oceanbase】centos7/kylinv10部署oceanbase(x86版本)
    反射、枚举及lambda表达式
    想要精通算法和SQL的成长之路 - 预测赢家
    oracle connect by详解
    MyBatis模糊查询
    北斗导航 | RTKLIB 2.4.3 在VS2015下的编译
  • 原文地址:https://blog.csdn.net/m0_73743794/article/details/133001620