QMacStyle::standardIcon returns icons that don't match the mac theme.
-
Using Qt 5.9.6 on Mac High Sierra, I'm tasked with creating a window with a custom titlebar, while maintaining some of the native look and feel across platforms.
I was hoping to grab the window control icons using QStyle::standardIcon, which I believe should be calling the implementation of QMacStyle::standardIcon
I'm passing QStyle::SP_TitleBarCloseButton, QStyle::SP_TitleBarMaxButton and QStyle::SP_TitleBarMinButton.
The icons that are returned don't match the native icons at all. Would an upgrade to Qt 5.12 help, or will I need to create my own images to try emulate the native look?
Alternative approaches also welcome!
-
Hi and welcome to devnet,
Upgrading is a good idea since 5.12 is the current LTS.
That said, what are you getting ?
-
Can you provide a minimal sample code that reproduces that ?
-
Here's a short sample, which results in the following window:
int main(int argc, char* argv[]) { QApplication app(argc, argv); QMainWindow window; QStyle *style = app.style(); QIcon closeIcon = style->standardIcon(QStyle::SP_TitleBarCloseButton); QPushButton button; button.setIcon(closeIcon); window.setCentralWidget(&button); window.show(); return app.exec(); }
-
-
I tested this out on 5.12, making sure to first specify
setStyle(QStyleFactory::create("macintosh"))
but got the same result.
Solution is to make images that look native and use those instead, not much of a solution but it seems to be the only option.