Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. ChartView with qml
Qt 6.11 is out! See what's new in the release blog

ChartView with qml

Scheduled Pinned Locked Moved Solved QML and Qt Quick
3 Posts 2 Posters 1.4k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    athandev
    wrote on last edited by athandev
    #1

    I'm trying to use a ChartView on my qml code, like this

    Rectangle {
        anchors.fill: parent
        color:"lightSteelBlue"
        BackEnd{
            id:myBackEnd
        }
        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 }
            }
        }
    
        Button{
    ...
    
    
    //This is my main function
    int main(int argc, char *argv[])
    {
        qmlRegisterType<BackEnd>("BackEnd", 1, 0, "BackEnd" );
        QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
        QGuiApplication app(argc, argv);
        mediator *m = new mediator();
    
        QQmlApplicationEngine engine;
        engine.rootContext()->setContextProperty("mediator",m);
    
        engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
        if (engine.rootObjects().isEmpty())
            return -1;
    
        return app.exec();
    }
    
    
    

    And this is the error I'm receiving
    "ASSERT: "!"No style available without QApplication!"" in file kernel\qapplication.cpp, line 1065"

    I've already try most solutions around internet, none worked

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi
      And you have the normal main.cpp that creates
      a QApplication instance ?

      #include <QApplication>
      #include <QQmlApplicationEngine>
      
      int main(int argc, char *argv[])
      {
          QApplication app(argc, argv);
      
          QQmlApplicationEngine engine;
          engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
      
          return app.exec();
      }
      
      A 1 Reply Last reply
      2
      • mrjjM mrjj

        Hi
        And you have the normal main.cpp that creates
        a QApplication instance ?

        #include <QApplication>
        #include <QQmlApplicationEngine>
        
        int main(int argc, char *argv[])
        {
            QApplication app(argc, argv);
        
            QQmlApplicationEngine engine;
            engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
        
            return app.exec();
        }
        
        A Offline
        A Offline
        athandev
        wrote on last edited by
        #3

        @mrjj
        no, I had "QGuiApplication app(argc, argv);" instead of " QApplication app(argc, argv);
        " I just changed this line and everything works fine ! thank you!!

        1 Reply Last reply
        1

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved