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. Getting data from dynamic objects in C++ or Python backend
QtWS25 Last Chance

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

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
4 Posts 2 Posters 345 Views
  • 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 Offline
    O Offline
    oscarthorn
    wrote on last edited by
    #1

    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
    0
    • GrecKoG Offline
      GrecKoG Offline
      GrecKo
      Qt Champions 2018
      wrote on last edited by
      #2
      This post is deleted!
      1 Reply Last reply
      0
      • GrecKoG Offline
        GrecKoG Offline
        GrecKo
        Qt Champions 2018
        wrote on last edited by
        #3

        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
        1
        • O Offline
          O Offline
          oscarthorn
          wrote on last edited by
          #4

          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
          0

          • Login

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