赞
踩
运行截图如下:
QDialog的样式表:
- QDialog{
- background-color:#4CAF50;
- }
-
- QPushButton{
- background-color: white;
- border: 2px solid #f44336;
- border-radius: 25px;
- padding: 15px 32px;
- }
-
- QPushButton:hover {
- background-color: #008CBA;
- color: white;
- border-radius: 25px;
- }
-
- QMessageBox{
- background-color:#008CBA
- }
QLineEdit样式表:
font: 26pt "Broadway";
QPushButton样式表:
font: 12pt "华文彩云";
源代码如下:
dialog.h
- #ifndef DIALOG_H
- #define DIALOG_H
-
- #include <QDialog>
-
- namespace Ui {
- class Dialog;
- }
-
- class Dialog : public QDialog
- {
- Q_OBJECT
-
- public:
- explicit Dialog(QWidget *parent = 0);
- ~Dialog();
-
- public slots:
- void btnClicked();
-
- private:
- Ui::Dialog *ui;
- };
-
- #endif // DIALOG_H
dialog.cpp
- #include "dialog.h"
- #include "ui_dialog.h"
- #include <QMessageBox>
-
- Dialog::Dialog(QWidget *parent) :
- QDialog(parent),
- ui(new Ui::Dialog)
- {
- ui->setupUi(this);
- connect(ui->pushButton,SIGNAL(clicked(bool)),this,SLOT(btnClicked()));
- this->setWindowTitle("CSDN IT1995");
- }
-
- void Dialog::btnClicked(){
- QMessageBox::information(this,"提示",ui->lineEdit->text());
- }
-
- Dialog::~Dialog()
- {
- delete ui;
- }
main.cpp
- #include "dialog.h"
- #include <QApplication>
-
- int main(int argc, char *argv[])
- {
- QApplication a(argc, argv);
- Dialog w;
- w.show();
-
- return a.exec();
- }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。