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. QQmlListProperty is read only

QQmlListProperty is read only

Scheduled Pinned Locked Moved Solved QML and Qt Quick
4 Posts 2 Posters 831 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.
  • L Offline
    L Offline
    Leon_2001
    wrote on last edited by
    #1

    Hello everyone,

    I created a class with a QQmlListProperty following exactly this example. But anytime I want to fill the list with values from qml (as they also did in this example), I get an error "property is read-only".
    From reading other Posts in the forum, it seems very likly that the the issue is that my type, which the QQmlListProperty stores, is not registered in qml.
    Well, I am using this in a plugin, so I made both classes (the class with QQmlListProperty, and the class stores in this list) available with qmlRegisterType.

    It's kind of hard to provide any source code, but I can't see any difference to the birthdayparty example except from the fact that it's a plugin.

    I appreciate any help!

    By the way, the birthdayparty example works.

    raven-worxR 1 Reply Last reply
    0
    • L Leon_2001

      Hello everyone,

      I created a class with a QQmlListProperty following exactly this example. But anytime I want to fill the list with values from qml (as they also did in this example), I get an error "property is read-only".
      From reading other Posts in the forum, it seems very likly that the the issue is that my type, which the QQmlListProperty stores, is not registered in qml.
      Well, I am using this in a plugin, so I made both classes (the class with QQmlListProperty, and the class stores in this list) available with qmlRegisterType.

      It's kind of hard to provide any source code, but I can't see any difference to the birthdayparty example except from the fact that it's a plugin.

      I appreciate any help!

      By the way, the birthdayparty example works.

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

      @Leon_2001
      did you really exactly implemented it like in the example?
      the important line is:

      QQmlListProperty<Person>(this, this,
                   &BirthdayParty::appendGuest,
                   &BirthdayParty::guestCount,
                   &BirthdayParty::guest,
                   &BirthdayParty::clearGuests);
      

      If you leave out the BirthdayParty::appendGuest function pointer it will result in a read-only list.

      @Leon_2001 said in QQmlListProperty is read only:

      Well, I am using this in a plugin, so I made both classes (the class with QQmlListProperty, and the class stores in this list) available with qmlRegisterType.

      you may also use QML_DECLARE_TYPE

      --- 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
      3
      • L Offline
        L Offline
        Leon_2001
        wrote on last edited by
        #3

        I tried to reproduce the problem without a plugin and I couldn't. That was the moment I realized, I forgot to make one class available to qml. It has pure virtual member functions, so qmlRegisterUncreatableType did the trick.

        @raven-worx When should I use QML_DECLARE_TYPE? (What's the difference except from the fact that it's a macro?)

        raven-worxR 1 Reply Last reply
        0
        • L Leon_2001

          I tried to reproduce the problem without a plugin and I couldn't. That was the moment I realized, I forgot to make one class available to qml. It has pure virtual member functions, so qmlRegisterUncreatableType did the trick.

          @raven-worx When should I use QML_DECLARE_TYPE? (What's the difference except from the fact that it's a macro?)

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

          @Leon_2001 said in QQmlListProperty is read only:

          When should I use QML_DECLARE_TYPE? (What's the difference except from the fact that it's a macro?)

          did you click on the link?

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