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. Searching for something like QQmlListProperty<QQmlComponent>
Qt 6.11 is out! See what's new in the release blog

Searching for something like QQmlListProperty<QQmlComponent>

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
3 Posts 3 Posters 631 Views 2 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.
  • S Offline
    S Offline
    sboehmann
    wrote on last edited by sboehmann
    #1

    Currently I use a QQmlListProperty<QObject> as DefaultProperty in my C++ class Foo and my QML looks like this:

    Foo {
        Bar {}
        Bar {}
        Bar {}
    }
    

    So nothing really exciting. However, I only need a few of these elements instantiated at the same time (and I already know which ones on the C++ side). My first idea was to use a QmlListProperty<QQQmlComponent>. That would be easy, but unfortunately it does not work.

    I can't change the QML code. But I want to control the instantiation of the elements on the C++ side. As if Bar would be implicitly assigned to a QQmlComponent in the above QML code. Hence the idea with the QQmlListProperty<QQmlComponent>, which unfortunately does not work.

    Does anyone have any ideas on how I could achieve this? Is there any (private) API that could help?

    Thank you in advance
    Stefan

    1 Reply Last reply
    0
    • DuBuD Offline
      DuBuD Offline
      DuBu
      wrote on last edited by
      #2

      Have you found a solution for your issue yet? I'm facing the same question.

      Cheers!

      raven-worxR 1 Reply Last reply
      0
      • DuBuD DuBu

        Have you found a solution for your issue yet? I'm facing the same question.

        Cheers!

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

        @DuBu
        i think there is no workaround yet other than wrapping all child items:

        Foo {
            Component { Bar {} }
            Component { Bar {} }
            Component { Bar {} }
        }
        

        But maybe this is indeed worth a feature request via the bugtracker.

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