Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct


    Qt World Summit: Early-Bird Tickets

    Unsolved How to report errors from custom QML components?

    QML and Qt Quick
    qml + js
    4
    9
    463
    Loading More Posts
    • 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.
    • Crawl.W
      Crawl.W last edited by

      Today, I encounter a error:

      Histogram_Plot.qml:95 Cannot assign to non-existent property "onDragChanged"

      Which is report by qmlscene.exe when I preview it. But When I wanna run the whole application, I got a white window. My main() use QQmlApplicationEngine, code as following:

      QQmlApplicationEngine engine;
      //other coding about initializing
      engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
      

      How could I locate error like qmlscene.exe reports when run application in the QtCreator.

      JonB 1 Reply Last reply Reply Quote 0
      • sierdzio
        sierdzio Moderators last edited by

        Is Histogram_Plot.qml a file from your project? Then go to line 95 in that file - this is where the error lies.

        (Z(:^

        Crawl.W 1 Reply Last reply Reply Quote 1
        • Crawl.W
          Crawl.W @sierdzio last edited by

          @sierdzio I know it. Just I need locate error when run the application and there are no hint in this mode.

          1 Reply Last reply Reply Quote 0
          • JonB
            JonB @Crawl.W last edited by

            @Crawl-W
            https://doc.qt.io/qt-5/qqmlapplicationengine.html#load-1 says:

            If an error occurs, error messages are printed with qWarning.

            You could look at accessing those via https://doc.qt.io/qt-5/qtglobal.html#qInstallMessageHandler.

            Or, what about https://doc.qt.io/qt-5/qqmlengine.html#warnings.

            ?

            Crawl.W 1 Reply Last reply Reply Quote 1
            • Crawl.W
              Crawl.W @JonB last edited by

              @JonB said in How to report errors from custom QML components?:

              uld look at accessing tho

              I tried the following code:

              QQmlApplicationEngine engine;
              QObject::connect(&engine, &QQmlApplicationEngine::warnings, [](const QList<QQmlError> warnings){qDebug() << warnings;});
              

              But, I got nothing.May there are no QQmlError being reported.
              Have you encountered such a problem? Any tricks?

              JonB 1 Reply Last reply Reply Quote 0
              • JonB
                JonB @Crawl.W last edited by

                @Crawl-W
                Then you do need to go down the https://doc.qt.io/qt-5/qtglobal.html#qInstallMessageHandler link route I showed you first. All qWarning() etc. messages go via this. You can write your own interceptor code and do whatever you want with the messages.

                Crawl.W 1 Reply Last reply Reply Quote 0
                • Crawl.W
                  Crawl.W @JonB last edited by Crawl.W

                  @JonB said in How to report errors from custom QML components?:

                  . messages go via this. You can write your own interceptor code and do whatever you want with the messages.

                  Still can't catch any exceptions. Direct run does not seem to do the inspection of qml objects, but qmlscene.exe does.

                  1 Reply Last reply Reply Quote 0
                  • GrecKo
                    GrecKo Qt Champions 2018 last edited by

                    Maybe there's no error, try adding an obvious syntax error in your code and watch the log.

                    Warning and errors are written to the console output by default.

                    Crawl.W 1 Reply Last reply Reply Quote 0
                    • Crawl.W
                      Crawl.W @GrecKo last edited by

                      @GrecKo Same code with qmlscene.exe will report error and can not preview UI.

                      1 Reply Last reply Reply Quote 0
                      • First post
                        Last post