Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QML different style using QGuiApplication and QCoreApplication



  • When i using QML in QCoreApplication all widgets have poor style:
    Slider in QGuiApplication:
    alt text

    In QCoreApplication:
    alt text

    Button in QGuiApp:

    alt text

    Button in QCoreApp:

    alt text

    Is there a way to resolve this problem?



  • With QApplication from QtWidgets you get a QStyle-based "Desktop" style. With QGuiApplication from QtGui, it is not possible to use QtWidgets so you get a QML-based "Base" style instead. You can specify QT_QUICK_CONTROLS_STYLE environment variable if you want to choose a specific style. Make sure to do it before loading any QML.

    QT_QUICK_CONTROLS_STYLE=Base ./app
    

    or in code:

    int main(...)
    {
        qputenv("QT_QUICK_CONTROLS_STYLE", "Base");
        ...
    }


  • With QApplication from QtWidgets you get a QStyle-based "Desktop" style. With QGuiApplication from QtGui, it is not possible to use QtWidgets so you get a QML-based "Base" style instead. You can specify QT_QUICK_CONTROLS_STYLE environment variable if you want to choose a specific style. Make sure to do it before loading any QML.

    QT_QUICK_CONTROLS_STYLE=Base ./app
    

    or in code:

    int main(...)
    {
        qputenv("QT_QUICK_CONTROLS_STYLE", "Base");
        ...
    }

Log in to reply