Connect QObject properties to a QQmlComponent
I'm trying to create an application similar to Scratch (placing graphical blocks instead of writing text) for trying to get children interested in programming. I'd really like to do it in QtQuick for nice animations etc., and I think it should be fully doable.
For getting the tree like structure I use something like "this":http://www.codeproject.com/Articles/664041/QML-QtQuick-TreeView-Model-Part-II , so each kind of delegate that has child items will end with a repeater.
My problem right now is getting the C++ <-> QML bridge to work, I'm currently trying to have QObject subclasses contain the data as properties and one "delegate" property that returns a QQmlComponent, the root items are then put into a list and given to QML.
The problem I'm currently having is connecting the data to the component (delegate), how would I do that?
Thanks in advance,
How do you set the model for the delegate(s)?
if you set your custom delegate to any kind of QML model view it should work out of the box with the attached property "modelData" to access your properties?
delegate: foo.delegate // where foo is your c++ QObject with the delegate property
that's just an example but you should be able to access the poperties of the delegate inside the repeater now (with modelData.xyz where xyz is a property in your delegate)
you can off course create your own view with an attached property like that or use a ListView or whatever has a model and delegate in the QtQuick components.
I hope that is what you want ^^
Nice, using the modelData property I managed to create a C++ function that gives me the data object for the modelData object (I'd thought there would be some other way though).