From 1cc33d599edbd6fb0ecaed10a029d86d0b67bafc Mon Sep 17 00:00:00 2001 From: laserpants Date: Mon, 18 Apr 2016 16:02:34 +0300 Subject: [PATCH] figure out how to use QStyle subclass properly --- main.cpp | 6 ++++++ style.cpp | 12 ++++++------ style.h | 4 ++-- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/main.cpp b/main.cpp index a793d67..02829c1 100644 --- a/main.cpp +++ b/main.cpp @@ -1,11 +1,17 @@ #include "mainwindow.h" #include +#include #include "style.h" int main(int argc, char *argv[]) { QApplication a(argc, argv); +// QCommonStyle *style = new QCommonStyle; +// a.setStyle(style); + +// a.setStyle(&Style::instance()); + MainWindow w; w.show(); diff --git a/style.cpp b/style.cpp index e0178ba..71bdb28 100644 --- a/style.cpp +++ b/style.cpp @@ -15,7 +15,7 @@ void Style::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPainter p->drawRect(opt->rect.adjusted(0, 0, -1, -1)); break; default: - QProxyStyle::drawPrimitive(pe, opt, p, w); + QCommonStyle::drawPrimitive(pe, opt, p, w); } } @@ -44,7 +44,7 @@ void Style::drawControl(ControlElement element, const QStyleOption *opt, break; */ default: - QProxyStyle::drawControl(element, opt, p, widget); + QCommonStyle::drawControl(element, opt, p, widget); } } @@ -63,7 +63,7 @@ QRect Style::subElementRect(SubElement sr, const QStyleOption *opt, } break; default: - r = QProxyStyle::subElementRect(sr, opt, widget); + r = QCommonStyle::subElementRect(sr, opt, widget); } // qDebug() << "r = " << r; @@ -80,7 +80,7 @@ void Style::drawComplexControl(ComplexControl cc, const QStyleOptionComplex *opt switch (cc) { default: - QProxyStyle::drawComplexControl(cc, opt, p, w); + QCommonStyle::drawComplexControl(cc, opt, p, w); } } @@ -93,7 +93,7 @@ QRect Style::subControlRect(ComplexControl cc, const QStyleOptionComplex *opt, S QRect r; switch (cc) { default: - r = QProxyStyle::subControlRect(cc, opt, sc, w); + r = QCommonStyle::subControlRect(cc, opt, sc, w); } // qDebug() << "r = " << r; @@ -116,7 +116,7 @@ int Style::pixelMetric(PixelMetric m, const QStyleOption *opt, const QWidget *wi ret = 0; break; default: - ret = QProxyStyle::pixelMetric(m, opt, widget); + ret = QCommonStyle::pixelMetric(m, opt, widget); } // qDebug() << "ret = " << ret; diff --git a/style.h b/style.h index d553e0e..deb830e 100644 --- a/style.h +++ b/style.h @@ -1,9 +1,9 @@ #ifndef STYLE_H #define STYLE_H -#include +#include -class Style : public QProxyStyle +class Style : public QCommonStyle { Q_OBJECT