当前位置:   article > 正文

Qt学习笔记-QSS装饰控件_qt border

qt border

运行截图如下:



QDialog的样式表:

  1. QDialog{
  2. background-color:#4CAF50;
  3. }
  4. QPushButton{
  5. background-color: white;
  6. border: 2px solid #f44336;
  7. border-radius: 25px;
  8. padding: 15px 32px;
  9. }
  10. QPushButton:hover {
  11. background-color: #008CBA;
  12. color: white;
  13. border-radius: 25px;
  14. }
  15. QMessageBox{
  16. background-color:#008CBA
  17. }

QLineEdit样式表:

font: 26pt "Broadway";

QPushButton样式表:

font: 12pt "华文彩云";


源代码如下:

dialog.h

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

dialog.cpp

  1. #include "dialog.h"
  2. #include "ui_dialog.h"
  3. #include <QMessageBox>
  4. Dialog::Dialog(QWidget *parent) :
  5. QDialog(parent),
  6. ui(new Ui::Dialog)
  7. {
  8. ui->setupUi(this);
  9. connect(ui->pushButton,SIGNAL(clicked(bool)),this,SLOT(btnClicked()));
  10. this->setWindowTitle("CSDN IT1995");
  11. }
  12. void Dialog::btnClicked(){
  13. QMessageBox::information(this,"提示",ui->lineEdit->text());
  14. }
  15. Dialog::~Dialog()
  16. {
  17. delete ui;
  18. }

main.cpp

  1. #include "dialog.h"
  2. #include <QApplication>
  3. int main(int argc, char *argv[])
  4. {
  5. QApplication a(argc, argv);
  6. Dialog w;
  7. w.show();
  8. return a.exec();
  9. }

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

闽ICP备14008679号