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.
  • Crawl.WC Offline
    Crawl.WC Offline
    Crawl.W
    wrote on 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.

    JonBJ 1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on 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(:^

      Crawl.WC 1 Reply Last reply
      1
      • sierdzioS sierdzio

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

        Crawl.WC Offline
        Crawl.WC Offline
        Crawl.W
        wrote on 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
        • Crawl.WC Crawl.W

          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.

          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on 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.

          ?

          Crawl.WC 1 Reply Last reply
          1
          • JonBJ JonB

            @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.WC Offline
            Crawl.WC Offline
            Crawl.W
            wrote on 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?

            JonBJ 1 Reply Last reply
            0
            • Crawl.WC Crawl.W

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

              JonBJ Offline
              JonBJ Offline
              JonB
              wrote on 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.

              Crawl.WC 1 Reply Last reply
              0
              • JonBJ JonB

                @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.WC Offline
                Crawl.WC Offline
                Crawl.W
                wrote on 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
                • GrecKoG Offline
                  GrecKoG Offline
                  GrecKo
                  Qt Champions 2018
                  wrote on 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.

                  Crawl.WC 1 Reply Last reply
                  0
                  • GrecKoG GrecKo

                    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.WC Offline
                    Crawl.WC Offline
                    Crawl.W
                    wrote on last edited by
                    #9

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

                    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