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. QTreeView inside QTableView cell
Forum Updated to NodeBB v4.3 + New Features

QTreeView inside QTableView cell

Scheduled Pinned Locked Moved General and Desktop
8 Posts 2 Posters 3.2k Views 1 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.
  • S Offline
    S Offline
    sampsont
    wrote on last edited by
    #1

    Is it possible to create a QTreeView inside a QTableView cell? I've looked at the Star Delegate example but I can't seem to make the leap to replacing the stars with a QTreeView. Can you give me any hints or direction? And as always, any sample code would be awesome!

    Thanks,
    Todd

    1 Reply Last reply
    0
    • S Offline
      S Offline
      sampsont
      wrote on last edited by
      #2

      Also, I'd like the QTreeView to be in the QTableView cell all the time, not just when the user double-clicks on the cell. None of the cells in the QTableView should be editable.

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

        Hi and welcome to devnet,

        Can you explain what you would like obtain exactly ?

        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
        • S Offline
          S Offline
          sampsont
          wrote on last edited by
          #4

          I am presenting the log results from a configuration management program called Ansible. I'm using a QTableView and a QSqlTableModel. As the results log text comes, I write it into the model and it is displayed in the view. The model never writes into the database.

          The big issue for me is that one column of the results from Ansible is a big Python dict that is several layers deep. If I just print the dict in the the QTableView, the user couldn't make heads or tails of it. I would like for the table to instead display the top keys in the dict with + signs so if the user is interested, they can expand the key and look at the hierarchy. The cell should expand to fit the expanded tree hierarchy.

          I could also imagine a context menu on the cell with 'expand all' and 'collapse all' menu items.

          Thanks!

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

            Then it looks more like QTreeViews in one QTreeView. But it's maybe a wrong design decision here. Why not have e.g. one QTreeView on the right of the QTableView and once a cell is selected, show the content in the QTreeView ?

            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
            • S Offline
              S Offline
              sampsont
              wrote on last edited by
              #6

              I think it's more like a QTreeView in the last column of a QTableView. For example, the Host, Timestamp, and severity are simple table elements. The Message is in a table but formatted as a Tree.
              @
              Host Timestamp Severity Message

              Station1 Aug 12 Critical > log
              Station12 Aug 12 Error > log
              Station15 Aug 12 Warning v log
              |--v Interfaces
              |--Eth0
              |-- ip:192.168.1.1
              @

              I think you might be suggesting that I display the Message column as plain text and then if you user clicks on it, display it elsewhere as a Tree. I'd rather just simply display the Message column as a Tree inside the Table if possible.

              Does this go against the grain for Qt? I think if I display the Message column as plain text, it would be worthless. It is quite big and ugly unless it's presented in a tree view. Another good thing about the tree view is that the default would be collapsed so it would fit easily in the table. If the user cares to expand it, then it would get big.

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

                No, I'm suggesting to have the tree view beside your table view so that you have a full sized widget to visualize the content of these messages. Otherwise you would have to "stretch" the row height to show a big enough tree view. Or did I misunderstood your idea ?

                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
                • S Offline
                  S Offline
                  sampsont
                  wrote on last edited by
                  #8

                  Ah. Now I understand. Yeah, I think that's a good idea. I'll give that a try.
                  Thanks!

                  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