Solved Using values set in QML properties as delegates that are used by C++ QtQuick object
-
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.
-
@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). -
If you only need an instance of an object, use a
QQuickItem*
property. That's what Controls do for theirbackground
property
If you need to create multiple instances use aQQmlComponent*
property. That what views do (like ListView) for theirdelegate
property.