Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. A tree like Qt object architecture and QML
Forum Update on Monday, May 27th 2025

A tree like Qt object architecture and QML

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 2 Posters 323 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.
  • B Offline
    B Offline
    Bremenpl
    wrote on 23 Apr 2019, 08:08 last edited by
    #1

    Hello there,
    In the project I am developing the requirements changed and it came out that my current way of connecting the Qt backend with QML frontend is not fit anymore. I had 2 classes that could talk to QML through context property. One of the class was one of its kind in the whole program, the other one was packed into a list.

    But now, the backend part looks like a tree... There has to be the main object, that has n second level objects inside, where each second level object has n third level objects inside etc... Now I need to figure out what is the best way of connecting the Qt part with QML together. When thinking about creating a property setter/ getter for each possible property (variable) my head starts to hurt. This has to be more universal and easy to extend, no matter how many branches/ levels/ properties are needed.

    0_1556006875920_e0294328-8173-48d8-8cbf-a6764d23804f-obraz.png

    I thought of creating a dedicated communication protocol, ie. a single pair of signal/ slot with dedicated data frame but this also seems hard to maintain in the longer run.

    I would appreciate all hints regarding this issue.

    lprzenioslo.zut.edu.pl

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 23 Apr 2019, 20:07 last edited by
      #2

      Hi,

      Wouldn't the MVC pattern be of help here ? You create a model that represents your tree of objects and interact with it rather than trying to make all objects available directly.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      B 1 Reply Last reply 23 Apr 2019, 20:13
      0
      • S SGaist
        23 Apr 2019, 20:07

        Hi,

        Wouldn't the MVC pattern be of help here ? You create a model that represents your tree of objects and interact with it rather than trying to make all objects available directly.

        B Offline
        B Offline
        Bremenpl
        wrote on 23 Apr 2019, 20:13 last edited by
        #3

        @SGaist hi, thanks for answer. Actually I am trying to do this with MVC, but I cant figure out how to do this properly in qml because of the tree architecture + the fact that each branch can exist in more than one instances.

        lprzenioslo.zut.edu.pl

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 23 Apr 2019, 20:26 last edited by
          #4

          It should be a tree of QObject and then you can use slots/Q_INVOKABLE methods/etc. to interact with them.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          1

          4/4

          23 Apr 2019, 20:26

          • Login

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