Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct


    Qt World Summit: Early-Bird Tickets

    Unsolved Getting data from dynamic objects in C++ or Python backend

    QML and Qt Quick
    2
    4
    99
    Loading More Posts
    • 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.
    • O
      oscarthorn last edited by

      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!

      1 Reply Last reply Reply Quote 0
      • GrecKo
        GrecKo Qt Champions 2018 last edited by

        This post is deleted!
        1 Reply Last reply Reply Quote 0
        • GrecKo
          GrecKo Qt Champions 2018 last edited by

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

          1 Reply Last reply Reply Quote 1
          • O
            oscarthorn last edited by

            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?

            1 Reply Last reply Reply Quote 0
            • First post
              Last post