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. Treeview for a sequence... it's worth to use a model?
Qt 6.11 is out! See what's new in the release blog

Treeview for a sequence... it's worth to use a model?

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 2 Posters 933 Views 2 Watching
  • 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.
  • M Offline
    M Offline
    Mark81
    wrote on last edited by
    #1

    I have to show a sequence of actions in a graphical form. The sequence is based upon a hierarchical structure, example:

    Section 1
        Group 1
            Action 1 | Description | Progress | State
            Action 2 | Description | Progress | State
            Action 3 | Description | Progress | State
        Group 2
            Action 1 | Description | Progress | State
            Action 2 | Description | Progress | State
            Action 3 | Description | Progress | State
    Section 2
        Group 1
            Action 1 | Description | Progress | State
            Action 2 | Description | Progress | State
            Action 3 | Description | Progress | State
        Group 2
            Action 1 | Description | Progress | State
            Action 2 | Description | Progress | State
            Action 3 | Description | Progress | State
    

    I think a treeview is the most suitable way to present this information.
    As you can guess, each row is update one by one changing the progress and the state.
    I would insert some custom QWidget in the cells, like progress bars, leds or any other stuff I need.

    I'm wondering if it's worth to use a model (and hence a QTreeView) for this use-case or it's easier to use a QTreeWidget where each cell is manually updated.

    My thoughts: the second way is more handy to display custom widgets but requires more code. Instead the model-based approach is more robust but more limited (unless you want to deal with a lot of delegates).

    Any other suggestion?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Your custom model will give you more flexibility. You can more easily change the view on top of it.

      As for your custom items in the cells: QStyledItemDelegate is the way to go.

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

      M 1 Reply Last reply
      1
      • SGaistS SGaist

        Hi,

        Your custom model will give you more flexibility. You can more easily change the view on top of it.

        As for your custom items in the cells: QStyledItemDelegate is the way to go.

        M Offline
        M Offline
        Mark81
        wrote on last edited by
        #3

        @SGaist said in Treeview for a sequence... it's worth to use a model?:

        As for your custom items in the cells: QStyledItemDelegate is the way to go.

        As far as I understand, with QStyledItemDelegate I have to subclass the paint() event in order to draw something "custom", haven't I? I mean, it's not possible to just set a QWidget and handle its signals/slots?

        I ask this because this way is quite simple with simple editors (like the start example of the Qt docs). But if you want to insert something more complex drawing everything manually in the paint() event doesn't seem so handy...

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          You'll end up with hundreds or even more widgets which will kill performances.

          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
          0

          • Login

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