QML type error.



  • Hi,

    I have a code base using QML. Upon running it, I get some errors (the code runs anyway and it is successfully reading the values as well).

    The error is something like:
    TypeError: Cannot read property 'something' of undefined

    This error is coming up when I try to access "something" from class "A" which is present in a QQmlListProperty "listOfA" present in class "C" set as context property under name "c" with namespace "namespace" version "1.0"

    So, I'm effectively typing:

    c.listOfA[some_index_number].something
    

    Note:

    • I currently have a Q_PROPERTY for a QQmlListProperty<A> type object.
    • I have a qmlRegisterType decleration for A:
      qmlRegisterUncreatableType<A>("namespace", 1, 0, "A", "Cannot create an object of type A");
    • The qml class linked in the error imports namespace 1.0

    Might I be suggested what I am missing here?


  • Moderators

    @Ankit.Jain
    such errors appear when you try to access c.listOfA too early before it has a proper value assigned


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.