figure out how to use QStyle subclass properly

This commit is contained in:
laserpants 2016-04-18 16:02:34 +03:00
parent 685ff75c7c
commit 1cc33d599e
3 changed files with 14 additions and 8 deletions

View File

@ -1,11 +1,17 @@
#include "mainwindow.h" #include "mainwindow.h"
#include <QApplication> #include <QApplication>
#include <QCommonStyle>
#include "style.h" #include "style.h"
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
QApplication a(argc, argv); QApplication a(argc, argv);
// QCommonStyle *style = new QCommonStyle;
// a.setStyle(style);
// a.setStyle(&Style::instance());
MainWindow w; MainWindow w;
w.show(); w.show();

View File

@ -15,7 +15,7 @@ void Style::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPainter
p->drawRect(opt->rect.adjusted(0, 0, -1, -1)); p->drawRect(opt->rect.adjusted(0, 0, -1, -1));
break; break;
default: 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; break;
*/ */
default: 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; break;
default: default:
r = QProxyStyle::subElementRect(sr, opt, widget); r = QCommonStyle::subElementRect(sr, opt, widget);
} }
// qDebug() << "r = " << r; // qDebug() << "r = " << r;
@ -80,7 +80,7 @@ void Style::drawComplexControl(ComplexControl cc, const QStyleOptionComplex *opt
switch (cc) { switch (cc) {
default: 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; QRect r;
switch (cc) { switch (cc) {
default: default:
r = QProxyStyle::subControlRect(cc, opt, sc, w); r = QCommonStyle::subControlRect(cc, opt, sc, w);
} }
// qDebug() << "r = " << r; // qDebug() << "r = " << r;
@ -116,7 +116,7 @@ int Style::pixelMetric(PixelMetric m, const QStyleOption *opt, const QWidget *wi
ret = 0; ret = 0;
break; break;
default: default:
ret = QProxyStyle::pixelMetric(m, opt, widget); ret = QCommonStyle::pixelMetric(m, opt, widget);
} }
// qDebug() << "ret = " << ret; // qDebug() << "ret = " << ret;

View File

@ -1,9 +1,9 @@
#ifndef STYLE_H #ifndef STYLE_H
#define STYLE_H #define STYLE_H
#include <QProxyStyle> #include <QCommonStyle>
class Style : public QProxyStyle class Style : public QCommonStyle
{ {
Q_OBJECT Q_OBJECT