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. How to report errors from custom QML components?

How to report errors from custom QML components?

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
qml + js
9 Posts 4 Posters 1.4k 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.
  • C Offline
    C Offline
    Crawl.W
    wrote on 25 Sept 2019, 11:51 last edited by
    #1

    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.

    J 1 Reply Last reply 26 Sept 2019, 01:57
    0
    • S Offline
      S Offline
      sierdzio
      Moderators
      wrote on 25 Sept 2019, 12:13 last edited by
      #2

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

      (Z(:^

      C 1 Reply Last reply 26 Sept 2019, 01:23
      1
      • S sierdzio
        25 Sept 2019, 12:13

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

        C Offline
        C Offline
        Crawl.W
        wrote on 26 Sept 2019, 01:23 last edited by
        #3

        @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
        0
        • C Crawl.W
          25 Sept 2019, 11:51

          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.

          J Offline
          J Offline
          JonB
          wrote on 26 Sept 2019, 01:57 last edited by
          #4

          @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.

          ?

          C 1 Reply Last reply 26 Sept 2019, 09:35
          1
          • J JonB
            26 Sept 2019, 01:57

            @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.

            ?

            C Offline
            C Offline
            Crawl.W
            wrote on 26 Sept 2019, 09:35 last edited by
            #5

            @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?

            J 1 Reply Last reply 26 Sept 2019, 15:07
            0
            • C Crawl.W
              26 Sept 2019, 09:35

              @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?

              J Offline
              J Offline
              JonB
              wrote on 26 Sept 2019, 15:07 last edited by
              #6

              @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.

              C 1 Reply Last reply 27 Sept 2019, 09:28
              0
              • J JonB
                26 Sept 2019, 15:07

                @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.

                C Offline
                C Offline
                Crawl.W
                wrote on 27 Sept 2019, 09:28 last edited by Crawl.W
                #7

                @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
                0
                • G Offline
                  G Offline
                  GrecKo
                  Qt Champions 2018
                  wrote on 27 Sept 2019, 10:14 last edited by
                  #8

                  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.

                  C 1 Reply Last reply 28 Sept 2019, 01:07
                  0
                  • G GrecKo
                    27 Sept 2019, 10:14

                    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.

                    C Offline
                    C Offline
                    Crawl.W
                    wrote on 28 Sept 2019, 01:07 last edited by
                    #9

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

                    1 Reply Last reply
                    0

                    9/9

                    28 Sept 2019, 01:07

                    • Login

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