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. QML "ChartView" crashing app
Qt 6.11 is out! See what's new in the release blog

QML "ChartView" crashing app

Scheduled Pinned Locked Moved Solved QML and Qt Quick
8 Posts 4 Posters 1.1k Views
  • 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.
  • B Offline
    B Offline
    BD9a
    wrote on last edited by
    #1

    Hey, I want to use ChartView to show statistics, but when trying to run my app just crashing. I heard about replacing QGuiApplication to QApplication, is it possible? I want QtQuick / QML, not QWidgets.

    :-1: error: Debugger encountered an exception: Exception at 0x3d34d8, code: 0xc0000005: read access violation at: 0x0, flags=0x0 (first chance)
    
    1 Reply Last reply
    0
    • B BD9a

      @JonB Nope, "QApplication file not found". My .pro file have this:

      QT += quick
      QT += quickcontrols2
      

      main.cpp

      #include <QApplication>
      #include <QQmlApplicationEngine>
      #include <QQmlContext>
      #include <Building/building.h>
      #include <Clicking/clicking.h>
      #include <Keytranslator/keytranslator.h>
      #include <Conf/conf.h>
      
      int main(int argc, char *argv[])
      {
      
          QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
      
          QGuiApplication app(argc, argv);
      
          QQmlApplicationEngine engine;
      
          Building building;
          Clicking clicking;
          KeyTranslator ktr;
          Conf config;
      
          building.config = &config;
          clicking.config = &config;
      
          config.create();
      
          building.loopStart();
          clicking.loopStart();
      
          QQmlContext *ctx = engine.rootContext();
          ctx->setContextProperty("Building", &building);
          ctx->setContextProperty("Clicking", &clicking);
          ctx->setContextProperty("keyTranslator", &ktr);
          ctx->setContextProperty("Config", &config);
      
          engine.rootContext()->setContextProperty("applicationDirPath", QGuiApplication::applicationDirPath());
          engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
      
          if (engine.rootObjects().isEmpty())
              return -1;
      
          return app.exec();
      }
      
      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #7

      @BD9a As stated in https://doc.qt.io/qt-5/qapplication.html
      You need

      QT += widgets
      

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      2
      • Quang PhuQ Offline
        Quang PhuQ Offline
        Quang Phu
        wrote on last edited by
        #2

        Hi @BD9a,
        I heard about replacing QGuiApplication to QApplication, is it possible?
        Yes, it's possible, change to QApplication, your QtQuict app still works fine!

        1 Reply Last reply
        0
        • B Offline
          B Offline
          BD9a
          wrote on last edited by
          #3

          But how? When I just replace

          QGuiApplication app(argc, argv);
          

          to

          QApplication app(argc, argv);
          

          I got error:

          variable has incomplete type 'QApplication'
          

          and more:
          alt text

          JonBJ 1 Reply Last reply
          0
          • B BD9a

            But how? When I just replace

            QGuiApplication app(argc, argv);
            

            to

            QApplication app(argc, argv);
            

            I got error:

            variable has incomplete type 'QApplication'
            

            and more:
            alt text

            JonBJ Offline
            JonBJ Offline
            JonB
            wrote on last edited by
            #4

            @BD9a
            Did you change to #include <QApplication> ?

            B 1 Reply Last reply
            0
            • JonBJ JonB

              @BD9a
              Did you change to #include <QApplication> ?

              B Offline
              B Offline
              BD9a
              wrote on last edited by
              #5

              @JonB Nope, "QApplication file not found". My .pro file have this:

              QT += quick
              QT += quickcontrols2
              

              main.cpp

              #include <QApplication>
              #include <QQmlApplicationEngine>
              #include <QQmlContext>
              #include <Building/building.h>
              #include <Clicking/clicking.h>
              #include <Keytranslator/keytranslator.h>
              #include <Conf/conf.h>
              
              int main(int argc, char *argv[])
              {
              
                  QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
              
                  QGuiApplication app(argc, argv);
              
                  QQmlApplicationEngine engine;
              
                  Building building;
                  Clicking clicking;
                  KeyTranslator ktr;
                  Conf config;
              
                  building.config = &config;
                  clicking.config = &config;
              
                  config.create();
              
                  building.loopStart();
                  clicking.loopStart();
              
                  QQmlContext *ctx = engine.rootContext();
                  ctx->setContextProperty("Building", &building);
                  ctx->setContextProperty("Clicking", &clicking);
                  ctx->setContextProperty("keyTranslator", &ktr);
                  ctx->setContextProperty("Config", &config);
              
                  engine.rootContext()->setContextProperty("applicationDirPath", QGuiApplication::applicationDirPath());
                  engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
              
                  if (engine.rootObjects().isEmpty())
                      return -1;
              
                  return app.exec();
              }
              
              JonBJ jsulmJ 2 Replies Last reply
              0
              • B BD9a

                @JonB Nope, "QApplication file not found". My .pro file have this:

                QT += quick
                QT += quickcontrols2
                

                main.cpp

                #include <QApplication>
                #include <QQmlApplicationEngine>
                #include <QQmlContext>
                #include <Building/building.h>
                #include <Clicking/clicking.h>
                #include <Keytranslator/keytranslator.h>
                #include <Conf/conf.h>
                
                int main(int argc, char *argv[])
                {
                
                    QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
                
                    QGuiApplication app(argc, argv);
                
                    QQmlApplicationEngine engine;
                
                    Building building;
                    Clicking clicking;
                    KeyTranslator ktr;
                    Conf config;
                
                    building.config = &config;
                    clicking.config = &config;
                
                    config.create();
                
                    building.loopStart();
                    clicking.loopStart();
                
                    QQmlContext *ctx = engine.rootContext();
                    ctx->setContextProperty("Building", &building);
                    ctx->setContextProperty("Clicking", &clicking);
                    ctx->setContextProperty("keyTranslator", &ktr);
                    ctx->setContextProperty("Config", &config);
                
                    engine.rootContext()->setContextProperty("applicationDirPath", QGuiApplication::applicationDirPath());
                    engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
                
                    if (engine.rootObjects().isEmpty())
                        return -1;
                
                    return app.exec();
                }
                
                JonBJ Offline
                JonBJ Offline
                JonB
                wrote on last edited by
                #6

                @BD9a
                I know nothing about QML, only widgets which is where I would do this, given your error message. @Quang-Phu said it was doable/fine, maybe you need clarification from him....

                1 Reply Last reply
                0
                • B BD9a

                  @JonB Nope, "QApplication file not found". My .pro file have this:

                  QT += quick
                  QT += quickcontrols2
                  

                  main.cpp

                  #include <QApplication>
                  #include <QQmlApplicationEngine>
                  #include <QQmlContext>
                  #include <Building/building.h>
                  #include <Clicking/clicking.h>
                  #include <Keytranslator/keytranslator.h>
                  #include <Conf/conf.h>
                  
                  int main(int argc, char *argv[])
                  {
                  
                      QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
                  
                      QGuiApplication app(argc, argv);
                  
                      QQmlApplicationEngine engine;
                  
                      Building building;
                      Clicking clicking;
                      KeyTranslator ktr;
                      Conf config;
                  
                      building.config = &config;
                      clicking.config = &config;
                  
                      config.create();
                  
                      building.loopStart();
                      clicking.loopStart();
                  
                      QQmlContext *ctx = engine.rootContext();
                      ctx->setContextProperty("Building", &building);
                      ctx->setContextProperty("Clicking", &clicking);
                      ctx->setContextProperty("keyTranslator", &ktr);
                      ctx->setContextProperty("Config", &config);
                  
                      engine.rootContext()->setContextProperty("applicationDirPath", QGuiApplication::applicationDirPath());
                      engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
                  
                      if (engine.rootObjects().isEmpty())
                          return -1;
                  
                      return app.exec();
                  }
                  
                  jsulmJ Offline
                  jsulmJ Offline
                  jsulm
                  Lifetime Qt Champion
                  wrote on last edited by
                  #7

                  @BD9a As stated in https://doc.qt.io/qt-5/qapplication.html
                  You need

                  QT += widgets
                  

                  https://forum.qt.io/topic/113070/qt-code-of-conduct

                  1 Reply Last reply
                  2
                  • B Offline
                    B Offline
                    BD9a
                    wrote on last edited by
                    #8

                    Thanks, it's working. I thought it's only QtQuick or QWidgets, not both.

                    1 Reply Last reply
                    0

                    • Login

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