Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Application Window Style

Tags:

c++

qt

qstyle

Though my operating system is Windows, I want my application to look like a Mac application. I know I can easily change that style using QApplication::setStyle.

QApplication::setStyle(new QWindowsVistaStyle)

I know Qt provide MacStyle too so, for MacStyle

QApplication::setStyle(new QMacStyle)

However, it seems QMacSytle is not declared. Compiler doesn't recognize it. And the Qt Webpage says

Warning: This style is only available on Mac OS X because it relies on the HITheme APIs.

Is there any other way to use that Mac OS style window? Because I need to use that.

like image 207
user3734823 Avatar asked Sep 14 '25 00:09

user3734823


1 Answers

Qt5 has new way to set style. For example:

QApplication a(argc, argv);
qDebug() << QStyleFactory::keys();
a.setStyle(QStyleFactory::create("Fusion"));

In my computer output is:

("Windows", "WindowsXP", "WindowsVista", "Fusion")

As you can see, mac os style is not available.

The QStyleFactory class creates QStyle objects.

The QStyle class is an abstract base class that encapsulates the look and feel of a GUI. QStyleFactory creates a QStyle object using the create() function and a key identifying the style. The styles are either built-in or dynamically loaded from a style plugin (see QStylePlugin).

The valid keys can be retrieved using the keys() function. Typically they include "windows" and "fusion". Depending on the platform, "windowsxp", "windowsvista", "gtk" and "macintosh" may be available. Note that keys are case insensitive.

like image 185
Kosovan Avatar answered Sep 16 '25 15:09

Kosovan