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. QML type error.

QML type error.

Scheduled Pinned Locked Moved Solved QML and Qt Quick
qmlregistertype
2 Posts 2 Posters 3.2k 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.
  • A Offline
    A Offline
    Ankit.Jain
    wrote on last edited by
    #1

    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?

    raven-worxR 1 Reply Last reply
    0
    • A Ankit.Jain

      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?

      raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #2

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

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      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