• C++ day3


     

     

    widget样式表

    1. *{
    2. background-color: rgb(255, 255, 255);
    3. }
    4. QFrame#frame{
    5. border-radius:25px;
    6. border-image: url(:/Logo/shanChuan.jpg);
    7. }
    8. #frame_2{
    9. border-radius:25px;
    10. background-color: rgba(154, 154, 154, 120);
    11. }
    12. QLabel#label{
    13. border-radius:25px;
    14. background-color: rgba(103, 103, 103, 120);
    15. }
    16. #label_2{
    17. background:transparent;
    18. color: white;
    19. font: 75 15pt "Times New Roman";
    20. color: rgba(255, 255, 255, 140);
    21. }
    22. QLineEdit{
    23. background:transparent;
    24. border:none;
    25. border-bottom:1px solid rgba(255, 255, 255, 120);
    26. color: rgba(255, 255, 255, 120);
    27. font: 9pt "Times New Roman";
    28. }
    29. QPushButton#pushButton{
    30. color: rgba(255, 255, 255, 120);
    31. font: 14pt "Times New Roman";
    32. background-color: qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:1, stop:0 rgba(46, 122, 214, 255), stop:1 rgba(255, 255, 255, 255));
    33. border-radius:5px;
    34. }
    35. QPushButton:hover#pushButton{
    36. color: rgba(255, 255, 255, 120);
    37. font: 14pt "Times New Roman";
    38. background-color: qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:1, stop:0 rgba(80, 122, 214, 255), stop:1 rgba(255, 255, 255, 255));
    39. border-radius:5px;
    40. }
    41. QPushButton:pressed#pushButton{
    42. color: rgba(255, 255, 255, 120);
    43. font: 14pt "Times New Roman";
    44. background-color: qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:1, stop:0 rgba(46, 122, 214, 255), stop:1 rgba(255, 255, 255, 255));
    45. border-radius:5px;
    46. padding-top:5px;
    47. padding-left:5px;
    48. }
    49. QPushButton#closeButton{
    50. background-color: transparent;
    51. border: none;
    52. font: 75 16pt "等线";
    53. border-radius:5px;
    54. }
    55. QPushButton:hover#closeButton{
    56. background-color: transparent;
    57. border: none;
    58. font: 75 16pt "等线";
    59. background-color: rgba(255, 0, 0, 80);
    60. border-radius:5px;
    61. }
    62. QPushButton:pressed#closeButton{
    63. background-color: transparent;
    64. border: none;
    65. font: 75 16pt "等线";
    66. border-radius:5px;
    67. padding-top:5px;
    68. padding-left:5px;
    69. }
    70. QPushButton#shrinkButton{
    71. background-color: transparent;
    72. border: none;
    73. border-radius:5px;
    74. font: 75 30pt "等线";
    75. }
    76. QPushButton:hover#shrinkButton{
    77. background-color: transparent;
    78. border: none;
    79. border-radius:5px;
    80. background-color: rgba(255, 238, 244, 80);
    81. font: 75 30pt "等线";
    82. }
    83. QPushButton:pressed#shrinkButton{
    84. background-color: transparent;
    85. border: none;
    86. font: 75 30pt "等线";
    87. border-radius:5px;
    88. padding-top:5px;
    89. padding-left:5px;
    90. }

    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_pushButton_clicked();
    16. void on_closeButton_clicked();
    17. void on_shrinkButton_clicked();
    18. signals:
    19. void jumpToSecondWindow();
    20. private:
    21. Ui::Widget *ui;
    22. };
    23. #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. {
    7. ui->setupUi(this);
    8. setWindowFlag(Qt::FramelessWindowHint);
    9. // 去掉空白
    10. setAttribute(Qt::WA_TranslucentBackground);
    11. }
    12. Widget::~Widget()
    13. {
    14. delete ui;
    15. }
    16. void Widget::on_pushButton_clicked()
    17. {
    18. if(ui->actLineEdit->text() == "admin" && ui->pwdLineEdit->text() == "123456")
    19. {
    20. close();
    21. emit jumpToSecondWindow();
    22. }
    23. else
    24. {
    25. QMessageBox::critical(this, "Login Error", "账号或密码错误!");
    26. // 清空账号和密码输入行
    27. ui->actLineEdit->clear();
    28. ui->pwdLineEdit->clear();
    29. }
    30. }
    31. void Widget::on_closeButton_clicked()
    32. {
    33. close();
    34. }
    35. void Widget::on_shrinkButton_clicked()
    36. {
    37. showMinimized();
    38. }

    Second.h

    1. #ifndef SECOND_H
    2. #define SECOND_H
    3. #include
    4. namespace Ui {
    5. class Second;
    6. }
    7. class Second : public QWidget
    8. {
    9. Q_OBJECT
    10. public:
    11. explicit Second(QWidget *parent = nullptr);
    12. ~Second();
    13. public slots:
    14. void mySlot();
    15. private:
    16. Ui::Second *ui;
    17. };
    18. #endif // SECOND_H

    Second.cpp

    1. #include "second.h"
    2. #include "ui_second.h"
    3. Second::Second(QWidget *parent) :
    4. QWidget(parent),
    5. ui(new Ui::Second)
    6. {
    7. ui->setupUi(this);
    8. }
    9. Second::~Second()
    10. {
    11. delete ui;
    12. }
    13. void Second::mySlot()
    14. {
    15. show();
    16. }

  • 相关阅读:
    mybatis关联关系映射
    Shell 实现文件基本操作(sed-编辑、awk-匹配)
    C++中的双冒号(::) 使用小结
    数一满分150分总分451东南大学920电子信息通信考研Jenny老师辅导班同学,真题大纲,参考书。
    【Java基础】方法注意事项、通用格式及方法重载
    遥感目标检测(1)--R3Det
    uniapp中用canvas实现小球碰撞的小动画
    SpringCloud - 服务调用组件OpenFeign使用详解(一)
    我服了!SpringBoot升级后这服务我一个星期都没跑起来!(上)
    Python数据分析----Numpy函数应用(二)
  • 原文地址:https://blog.csdn.net/2301_81402136/article/details/139753883