Getting data from dynamic objects in C++ or Python backend
-
Hi!
I'm a new to Qt and QML so perhaps this is obvious, but I'm looking for a best practice solution.My problem is that I am designing a program that will need to have a sort of visual builder for logical rules (if A is X or Y and Z then B). My plan is to do this with dynamic elements. So the user clicks a button to add/delete a rule element and then when they are done they click finished and at that point the backend will need to parse the rule. So I will need to get the data from the dynamic components. How do I do that? I know how to do it with properties for normal components but the number of components will not be known so...
Grateful for any help of pointers!
-
This post is deleted!
-
You don't do it.
Instead you create your data in c++/Python and you display it in QML.
For example, when you click your add button, the QML side should call a c++ function to add a new rule. The c++ should then update one of its model/list properties and the qml should just display the list with a ListView/Repeater.
Think in terms of data and not visual objects.
The c++/Python side owns the data, the QML displays it and can ask for it to be modified.Don't try to reach QML objects from C++
-
Ah, that makes sense, thanks!
But can I display a list of custom components in a listview? So I add, for example, an AND component that consists of two comboboxes in the list in the backend and that displays it in the frontend. And then when the user is done I can just go through the components in the list and get the selections. Is that the idea?