feat: Create class MyStyle: public QCommonStyle; and most of its overloaded virtual functions (prepared)
This commit is contained in:
@@ -20,6 +20,7 @@
|
||||
*/
|
||||
|
||||
#include "widget.h"
|
||||
#include "mystyle.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QTableWidget>
|
||||
@@ -74,7 +75,9 @@ void Widget::init()
|
||||
|
||||
int i = 0;
|
||||
QStringList listStyle = QStyleFactory::keys();
|
||||
foreach(QString val, listStyle) { //打印当前系统支持的系统风格
|
||||
|
||||
//显示 and 使用当前系统支持的系统风格
|
||||
foreach(QString val, listStyle) {
|
||||
qDebug()<<val<<" ";
|
||||
QPushButton *btn = new QPushButton(val, this);
|
||||
btn->move(this->rect().right() - 100, this->rect().top() + i++ * 40);
|
||||
@@ -83,4 +86,11 @@ void Widget::init()
|
||||
});
|
||||
}
|
||||
|
||||
//若是自定义风格, new 为对象即可
|
||||
QPushButton *btn = new QPushButton("My Style", this);
|
||||
btn->move(this->rect().right() - 100, this->rect().top() + i++ * 40);
|
||||
connect(btn, &QPushButton::clicked, this, [=](){
|
||||
qApp->setStyle(new MyStyle());
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user