• 6月15号作业


    使用手动连接,将登录框中的取消按钮使用第二中连接方式,右击转到槽,在该槽函数中,调用关闭函数

    将登录按钮使用qt4版本的连接到自定义的槽函数中,在槽函数中判断ui界面上输入的账号是否为"admin",密码是否为"123456",如果账号密码匹配成功,则输出“登录成功”,并关闭该界面,如果匹配失败,则输出登录失败,并将密码框中的内容清空

    widget.h

    1. #ifndef WIDGET_H
    2. #define WIDGET_H
    3. #include
    4. #include
    5. QT_BEGIN_NAMESPACE
    6. namespace Ui { class Widget; }
    7. QT_END_NAMESPACE
    8. class Widget : public QWidget
    9. {
    10. Q_OBJECT
    11. public:
    12. Widget(QWidget *parent = nullptr);
    13. ~Widget();
    14. private slots:
    15. void on_canceBin_clicked();
    16. void my_slot();
    17. void on_pos2_clicked();
    18. private:
    19. Ui::Widget *ui;
    20. QTextEdit *text1;
    21. };
    22. #endif // WIDGET_H

    widget.cpp

    1. #include "widget.h"
    2. #include "ui_widget.h"
    3. Widget::Widget(QWidget *parent)
    4. : QWidget(parent)
    5. , ui(new Ui::Widget)
    6. ,text1(new QTextEdit)
    7. {
    8. ui->setupUi(this);
    9. ui->bel1->setPixmap(QPixmap(":/pictrue/logo.png"));//标签贴图的路劲
    10. ui->bel1->setScaledContents(true);//自动适应调节
    11. ui->bel2->setPixmap(QPixmap(":/pictrue/wodepeizhenshi.png"));//标签贴图的路劲
    12. ui->bel2->setScaledContents(true);//自动适应调节
    13. ui->bel3->setPixmap(QPixmap(":/pictrue/passwd.jpg"));//标签贴图的路劲
    14. ui->bel3->setScaledContents(true);//自动适应调节
    15. ui->idt2->setEchoMode(QLineEdit::Password);//设置密码
    16. connect(ui->pos1,SIGNAL(clicked()),this,SLOT(my_slot()));
    17. // connect(text1,SIGNAL(),this,SLOT(my_slot()));
    18. }
    19. Widget::~Widget()
    20. {
    21. delete ui;
    22. }
    23. void Widget::my_slot()
    24. {
    25. if(ui->idt1->text()=="123456")
    26. {
    27. if(ui->idt2->text()=="123456")
    28. {
    29. text1->setText("登录成功");
    30. text1->resize(80,50);
    31. text1->show();
    32. this->close();
    33. return;
    34. }
    35. }
    36. text1->setText("登录失败");
    37. ui->idt2->setText("");
    38. text1->resize(80,50);
    39. text1->show();
    40. }
    41. void Widget::on_canceBin_clicked()
    42. {
    43. this->close();
    44. }
    45. void Widget::on_pos2_clicked()
    46. {
    47. this->close();
    48. }

    功能实现

    思维导图

  • 相关阅读:
    JVM 虚拟机 ---->垃圾收集算法
    微服务与单体应用有什么区别?
    rocketmq4.9 linux安装
    国芯方案——电子吊钩秤方案
    学信息系统项目管理师第4版系列25_项目绩效域(上)
    【python数据建模】Pandas库
    张驰咨询:企业实施精益管理的最大障碍,只把精益作为一种工具和方法
    使用 stream buffer 传递数据
    uniapp中video播放视频上按钮没显示的问题
    算法 | 算法是什么?深入精讲
  • 原文地址:https://blog.csdn.net/sgjxbpdhc/article/details/139725601