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. Using values set in QML properties as delegates that are used by C++ QtQuick object
Forum Updated to NodeBB v4.3 + New Features

Using values set in QML properties as delegates that are used by C++ QtQuick object

Scheduled Pinned Locked Moved Solved QML and Qt Quick
3 Posts 3 Posters 306 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.
  • fcarneyF Offline
    fcarneyF Offline
    fcarney
    wrote on last edited by
    #1

    I am writing a QtQuick based C++ object. I was wondering if there is a way to use an object set as a property of that object:

    Object {
      delegateObject: Item{}
    }
    

    Where delegateObject is set to a QML object that can be used as a delegate in the QtQuick C++ object. I am creating a C++ object so I can draw some things fast using QSGNodes, but would like to draw other things using QML objects. I assume I would need to somehow read the nodes from the delegate and then generate them at render time. Not sure how this would affect events.

    C++ is a perfectly valid school of magic.

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      @fcarney said in Using values set in QML properties as delegates that are used by C++ QtQuick object:

      delegateObject

      Declare delegateObject as a pointer to QQuickItem. That part should work. However, I have no idea if/ how to the other step (pain the delegate on demand).

      (Z(:^

      1 Reply Last reply
      1
      • GrecKoG Offline
        GrecKoG Offline
        GrecKo
        Qt Champions 2018
        wrote on last edited by
        #3

        If you only need an instance of an object, use a QQuickItem* property. That's what Controls do for their background property
        If you need to create multiple instances use a QQmlComponent* property. That what views do (like ListView) for their delegate property.

        1 Reply Last reply
        2

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved