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. QQmlComponent ReferenceError not coming through via errors()
Forum Updated to NodeBB v4.3 + New Features

QQmlComponent ReferenceError not coming through via errors()

Scheduled Pinned Locked Moved QML and Qt Quick
3 Posts 2 Posters 800 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.
  • K Offline
    K Offline
    kiro
    wrote on last edited by
    #1

    Hi all.

    I use the following code to test if a QML script compiles before embedding it in a bigger script:
    @
    m_scriptComponent = new QQmlComponent(m_liveView->quickView()->engine());
    m_scriptComponent->setData("import QtQuick 2.0\n" + m_scriptText.toUtf8(), QUrl());
    QList<QQmlError> scriptErrors = m_scriptComponent->errors();
    @
    This works fine and scriptErrors is filled when most errors occur. What does NOT get reported is ReferenceErrors. Say I have the script line:
    @
    property bool bla: fals
    @
    I get the following error in the application output, but not in errors():
    @
    qrc:/renderScript:7: ReferenceError: fals is not defined
    @

    What should I do to retrieve those errors?!

    1 Reply Last reply
    0
    • M Offline
      M Offline
      melghawi
      wrote on last edited by
      #2

      I remember having to do something similar where I would display all qml errors to the user.

      I'm not sure if there is a cleaner way to do this but what I did was to install a new message handler and then intercept application messages and filter errors.

      I guess you can have a global error list that gets populated by a custom message handler which you can then access from anywhere in your application. Maybe you can clear the list after each access. Depends on your requirements.

      Or you could have multiple lists e.g: qmlReferenceErrors, qmlScriptErrors, etc, which would also be populated by a custom message handler.

      I do not remember finding a list of reference errors anywhere.

      Please do let us know if you find a cleaner way to do this.

      1 Reply Last reply
      0
      • K Offline
        K Offline
        kiro
        wrote on last edited by
        #3

        Thanks for answering. Will try this out when I find time.
        Could you elaborate on what message handle to install. I'm a newbie to QML, so I don't really have an idea what to use... :/

        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