QtCharts app won't run (The program has unexpectedly finished.)



  • I use Qt 5.7 and get the QtCharts examples up and running just fine. But when I try to build a simple app to display
    chart, it's just not running (with the message "The program has unexpectedly finished."). I believe I have setup everything
    to use QtCharts correctly (follow the example). Am I missing anything?

    Here's my .pro file

    QT += qml quick charts core gui widgets
    
    CONFIG += c++11
    
    SOURCES += main.cpp
    
    RESOURCES += qml.qrc
    
    

    Here's my simple qml to display chart.

    import QtQuick 2.0
    import QtCharts 2.0
    
    Item {
        anchors.fill: parent
    
        //![1]
        ChartView {
            title: "Line"
            anchors.fill: parent
            antialiasing: true
    
            LineSeries {
                name: "LineSeries"
                XYPoint { x: 0; y: 0 }
                XYPoint { x: 1.1; y: 2.1 }
                XYPoint { x: 1.9; y: 3.3 }
                XYPoint { x: 2.1; y: 2.1 }
                XYPoint { x: 2.9; y: 4.9 }
                XYPoint { x: 3.4; y: 3.0 }
                XYPoint { x: 4.1; y: 3.3 }
            }
        }
        //![1]
    }
    
    

    Any help would be appreciated.

    :D:D:D



  • Found it. Right there in the example file.

    // Qt Charts uses Qt Graphics View Framework for drawing, therefore QApplication must be used.
    

    So switching to QApplication solved my problem.

    Thanks!

    :D:D:D


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.