Qt World Summit: Register Today!

How to resolve this error ASSERT: “!”No style available without QApplication!“” in file kernel\qapplication.cpp, line 1054?

  • When I start application to display a chart it presents me with this error:


    QML debugging is enabled. Only use this in a safe environment. ASSERT: "!"No style available without QApplication!"" in file kernel\qapplication.cpp, line 1054 ASSERT: "!"No style available without QApplication!"" in file kernel\qapplication.cpp, line 1054


    QT += quick
    CONFIG += c++11
    # The following define makes your compiler emit warnings if you use
    # any feature of Qt which as been marked deprecated (the exact warnings
    # depend on your compiler). Please consult the documentation of the
    # deprecated API in order to know how to port your code away from it.
    # You can also make your code fail to compile if you use deprecated APIs.
    # In order to do so, uncomment the following line.
    # You can also select to disable deprecated APIs only up to a certain version of Qt.
    #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0
    SOURCES += \
    RESOURCES += qml.qrc
    # Additional import path used to resolve QML modules in Qt Creator's code model
    # Additional import path used to resolve QML modules just for Qt Quick Designer
    # Default rules for deployment.
    qnx: target.path = /tmp/$${TARGET}/bin
    else: unix:!android: target.path = /opt/$${TARGET}/bin
    !isEmpty(target.path): INSTALLS += target


    #include <QGuiApplication>
    #include <QQmlApplicationEngine>
     int main(int argc, char *argv[])
    QGuiApplication app(argc, argv);
    QQmlApplicationEngine engine;
    if (engine.rootObjects().isEmpty())
        return -1;
    return app.exec();


    import QtQuick 2.9
    import QtQuick.Window 2.2
    import QtCharts 2.0
    import QtQuick 2.0
    Window {
    visible: true
    width: 640
    height: 480
    title: qsTr("Hello World")
    ChartView {
        width: 400
        height: 300
        theme: ChartView.ChartThemeBrownSand
        antialiasing: true
        PieSeries {
            id: pieSeries
            PieSlice { label: "eaten"; value: 94.9 }
            PieSlice { label: "not yet eaten"; value: 5.1 }

  • Moderators

    as the error says:
    Instantiate a QApplication instead of a QGuiApplication in your main()

  • Moderators

    @raven-worx is right, you have to replace GuiApplication with QApplication, the reason for this is your use of QCharts

    take a look at the docu

    Note: Projects created with Qt Creator's Qt Quick Application wizard are based on the Qt Quick 2 template that uses QGuiApplication by default. All such QGuiApplication instances in the project must be replaced with QApplication as the module depends on Qt's Graphics View Framework for rendering.

    Because QCharts is it's own modul, you'll prob also have to add QT += charts to your project file.

  • Thank you very much guys, it worked.

Log in to reply