4

Is it possible to obtain a text file of the entire Qt5 StyleSheet for QMacStyle (or its equivalent QProxyStyle that's apparently used in Qt5)?

I'm hoping to get a list of all the property:value pairs ('background-color', 'border-radius', 'margin-top', 'padding', etc.), along with their default settings, that are used for each of the common widgets (QPushButton, QTabBar, etc.).

Qt5 on Mac OSX looks great due to all of the native-looking widgets (see e.g. Macintosh Style Widget Gallery). I'd like to perform some surgical replacements of a number of style properties in my application, but otherwise keep the native look-and-feel. (An alternate take on the problem, or at least on the same end goal, is represented in my related question How to override just one property:value pair in Qt StyleSheet.)

If I knew the entire Qt StyleSheet equivalent for a QTabBar or QPushButton, I could reconstruct the native look-and-feel in my own invocations of widget->setStyleSheet(), adding in my few necessary tweaks.

I've searched the entire Qt5.4.0 directory hoping to find a *.qss file representing OSX style, but to no avail (I found the promisingly named examples/widgets/widgets/stylesheet/qss/default.qss, however all it says inside is //* empty stylesheet *//). I've exhausted my ideas running grep on the full Qt5 source directory, including in qt-everywhere-enterprise-src-5.4.0/qtbase/src/widgets/styles/, which may indeed contain the details but not in very digestible form).

Thanks --

Community
  • 1
  • 1
lcikgl
  • 759
  • 1
  • 8
  • 20
  • [random internet result](https://github.com/ganzziani/xscopes-qt/blob/master/mac-css.qss) – GPPK Mar 03 '15 at 21:14
  • Thanks @GPPK, that's the right idea however that appears to be someone's own styling for Mac in their own project, not an equivalent to the QMacStyle defaults – lcikgl Mar 03 '15 at 21:22

1 Answers1

3

QMacStyle is a QStyle subclass that is using Apple's HITheme for drawing (look for the files qmacstyle_mac* to see the implementation), so there is no stylesheet to obtain.

Linville
  • 3,613
  • 1
  • 27
  • 41
  • OK @Linville, thanks -- a newbie question after a bunch of internet and man-page searching: am I to understand that QStyle() and QStyleSheet() are two completely separate ways to style QWidgets, and they're mutually exclusive, i.e. you have to choose either one or the other approach? – lcikgl Mar 04 '15 at 22:48
  • It's beginning to appear that QStyle() and stylesheets are indeed mutually exclusive, when I see tutorials such as this: [How to Change the Background Color of a QWidget](http://wiki.qt.io/How_to_Change_the_Background_Color_of_QWidget) – lcikgl Mar 05 '15 at 22:01
  • [QWidget#setStyle](http://doc.qt.io/qt-5/qwidget.html#setStyle) says `Warning: Qt style sheets are currently not supported for custom QStyle subclasses. We plan to address this in some future release.` Perhaps that comment applies here – lcikgl Mar 05 '15 at 22:04
  • Closing in on a solid understanding here. [This post](http://stackoverflow.com/questions/4434604/determining-qt-stylesheet-options-programmatically/6461901#6461901) suggests stylesheets are a layer above QStyle()s – lcikgl Mar 06 '15 at 15:48
  • 5
    To comprehend @Linville's correct answer from newbie perspective, one must understand that QStyle() and StyleSheets exist at different layers. My original question was on bad premise. StyleSheets are implemented on top of QStyle(). In `qtbase/src/widgets/kernel/qapplication.cpp` we see that `QApplication::setStyleSheet()` creates an instance of QStyleSheetStyle (a subclass of QStyle) and replaces the application stylesheet with it. Calling setStyleSheet() thus displaces QMacStyle entirely. One must choose to work entirely in QStyleSheetStyle() (via setStyleSheet()), or entirely in QMacStyle(). – lcikgl Mar 06 '15 at 16:18