虽然我的操作系统是 Windows,但我希望我的应用程序看起来像 Mac 应用程序。我知道我可以使用 QApplication::setStyle
轻松更改该样式。
QApplication::setStyle(new QWindowsVistaStyle)
我知道 Qt
也提供 MacStyle
,对于 MacStyle
QApplication::setStyle(new QMacStyle)
但是,QMacSytle
似乎没有声明。编译器无法识别它。 Qt
网页显示
Warning: This style is only available on Mac OS X because it relies on the HITheme APIs.
还有其他方法可以使用 Mac OS
风格的窗口吗?因为我需要使用它。
最佳答案
Qt5
具有设置样式的新方法。例如:
QApplication a(argc, argv);
qDebug() << QStyleFactory::keys();
a.setStyle(QStyleFactory::create("Fusion"));
在我的电脑输出是:
("Windows", "WindowsXP", "WindowsVista", "Fusion")
如您所见,mac os 样式不可用。
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.
关于c++ - 应用程序窗口样式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27702635/