Qt GUI theme looks old-fashioned

后端 未结 4 1663
有刺的猬
有刺的猬 2021-02-12 18:54

When I cross-compile Qt 5.8.0 from source myself and use it to build the Qt \"Dynamic Layouts\" example from Qt Widgets for Microsoft Windows, it looks old-fashioned, as if it w

4条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-02-12 19:19

    Widgets

    Qt-based GUIs will automatically select the default theme depending on your OS. If you want to override it, you are looking for QApplication's setStyle method, which lets you define the style used for your application, regardless of the OS it runs on.

    QApplication::setStyle("fusion");
    

    From the documentation, the following are supported:

    • "windows"
    • "fusion"
    • "windowsxp"
    • "macintosh"

    The supported themes depend on your platform, and can be extended with plugins.


    EDIT: This answer targets situations where the OS is correctly detected by Qt configuration step, and you just want to change the theme used. In the situation described, the incorrect theme was selected, which is fixed in OP's answer.

    Qt Quick

    If your GUI is based on QtQuick instead of Widgets, you can use QQuickStyle::setStyle("Material"); instead to customize the theme that you want to see used.

    For more details, you can look at that documentation page:

    • https://doc.qt.io/qt-5/qtquickcontrols2-styles.html#using-styles-in-qt-quick-controls-2

提交回复
热议问题