当前位置:   article > 正文

Qt day3

Qt day3

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. {
  7. ui->setupUi(this);
  8. this->setWindowFlag(Qt::FramelessWindowHint);
  9. this->setAttribute(Qt::WA_TranslucentBackground);//去掉空白部分
  10. }
  11. Widget::~Widget()
  12. {
  13. delete ui;
  14. }
  15. void Widget::on_pushButton_clicked()
  16. {
  17. if(ui->lineEdit->text()=="SteamId:admin"&&ui->lineEdit_2->text()=="Passwd:1")
  18. {
  19. int res = QMessageBox::information(this,"information","Log in success",QMessageBox::Ok);
  20. if(QMessageBox::Ok==res)
  21. {
  22. this->close();
  23. }
  24. }
  25. else
  26. {
  27. int res = QMessageBox::information(this,
  28. "information",
  29. "The account and password do not match,Do you want to log in again",
  30. QMessageBox::Yes|QMessageBox::No);
  31. if(res==QMessageBox::Yes)
  32. {
  33. ui->lineEdit_2->clear();
  34. QMessageBox::information(this,"information","continue Log in",QMessageBox::Ok);
  35. }
  36. }
  37. }

widget.h

  1. #ifndef WIDGET_H
  2. #define WIDGET_H
  3. #include <QWidget>
  4. #include <QMessageBox>
  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_pushButton_clicked();
  16. private:
  17. Ui::Widget *ui;
  18. };
  19. #endif // WIDGET_H

 样式表代码

  1. *{
  2. background-color:rgb(255,255,255)
  3. }
  4. QFrame#frame{
  5. border-image: url(:/Logo/AK.png);
  6. }
  7. #frame_2{
  8. background-color: rgba(185, 184, 184, 100);
  9. }
  10. QLabel#label{
  11. border-radius:30px;
  12. background-color: rgba(79, 79, 79, 100);
  13. }
  14. #label_2{
  15. background:transparent;
  16. font: 75 16pt "华文行楷";
  17. color: rgba(255, 255, 255, 100);
  18. }
  19. #label_3{
  20. background:transparent;
  21. font: 75 8pt "微软雅黑";
  22. color: rgba(255, 255, 255, 100);
  23. }
  24. QLineEdit{
  25. background:transparent;
  26. border:none;
  27. border-bottom:1px solid rgba(255, 255, 255, 100);
  28. font: 8pt "微软雅黑";
  29. color: rgba(255, 255, 255, 100);
  30. }
  31. QPushButton{
  32. border-radius:10px;
  33. background-color: qlineargradient(spread:reflect, x1:0.469, y1:0.238636, x2:1, y2:1, stop:0 rgba(90, 123, 233, 254), stop:1 rgba(255, 255, 255, 255));
  34. font: 75 10pt "微软雅黑";
  35. color: rgba(255, 255, 255, 100);
  36. }
  37. QPushButton:hover{/*鼠标的移动*/
  38. border-radius:10px;
  39. background-color: qlineargradient(spread:reflect, x1:0.469, y1:0.238636, x2:1, y2:1, stop:0 rgba(48, 123, 233, 254), stop:1 rgba(255, 255, 255, 255));
  40. font: 75 10pt "微软雅黑";
  41. color: rgba(255, 255, 255, 100);
  42. }
  43. QPushButton:pressed{/*鼠标点击*/
  44. border-radius:10px;
  45. background-color: qlineargradient(spread:reflect, x1:0.469, y1:0.238636, x2:1, y2:1, stop:0 rgba(90, 123, 233, 254), stop:1 rgba(255, 255, 255, 255));
  46. font: 75 10pt "微软雅黑";
  47. color: rgba(255, 255, 255, 100);
  48. padding-top:5px;
  49. padding-left:5px;
  50. }

 成功登录

登录失败

 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/知新_RL/article/detail/153887
推荐阅读
  

闽ICP备14008679号