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 can span children's items to a new item
Forum Update on Monday, May 27th 2025

QTreeView can span children's items to a new item

Scheduled Pinned Locked Moved Unsolved General and Desktop
7 Posts 4 Posters 550 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.
  • J Offline
    J Offline
    jinming
    wrote on last edited by
    #1

    Hi, all, QTreeView has the ability to span children's items like QTableView::setSpan? For example, below the picture, I want to span the item "111", "222", "333" to a new item.But I can't find the QTreeView api to do this work. Do you have a good idea? Thanks a lot.

    treeview_span.png

    SGaistS JonBJ 2 Replies Last reply
    0
    • J jinming

      Hi, all, QTreeView has the ability to span children's items like QTableView::setSpan? For example, below the picture, I want to span the item "111", "222", "333" to a new item.But I can't find the QTreeView api to do this work. Do you have a good idea? Thanks a lot.

      treeview_span.png

      SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      No it does not.

      Can you explain how you would like to show your data ? A drawing might help as well.

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

      J 1 Reply Last reply
      0
      • J jinming

        Hi, all, QTreeView has the ability to span children's items like QTableView::setSpan? For example, below the picture, I want to span the item "111", "222", "333" to a new item.But I can't find the QTreeView api to do this work. Do you have a good idea? Thanks a lot.

        treeview_span.png

        JonBJ Online
        JonBJ Online
        JonB
        wrote on last edited by JonB
        #3

        @jinming
        The only spanning available is void QTreeView::setFirstColumnSpanned(int row, const QModelIndex &parent, bool span). That would be for just the case where you want first column to span all other columns and they don't get shown.

        Otherwise you have to do quite some work (delegate or subclassing) to do this, maybe suggest you follow @SGaist's request for a drawing so we're sure what's wanted.

        1 Reply Last reply
        0
        • SGaistS SGaist

          Hi,

          No it does not.

          Can you explain how you would like to show your data ? A drawing might help as well.

          J Offline
          J Offline
          jinming
          wrote on last edited by
          #4

          @SGaist Hi, I want to make a UI to display signal which is decoded by CAN data, like the below picture shows.

          treeview_span_explain.png
          It has the header "Time | Chn | ID | Name | ...." like QTreeView header, but the children has some difference, example, children item "EngTemp 86 degC 44" has the space between column "Time | Chn | ID | Name", I think this is suitable, because the information("EngTemp 86 degC 44") is too big. Does QT has the method to make it.

          SGaistS M 2 Replies Last reply
          0
          • J jinming

            @SGaist Hi, I want to make a UI to display signal which is decoded by CAN data, like the below picture shows.

            treeview_span_explain.png
            It has the header "Time | Chn | ID | Name | ...." like QTreeView header, but the children has some difference, example, children item "EngTemp 86 degC 44" has the space between column "Time | Chn | ID | Name", I think this is suitable, because the information("EngTemp 86 degC 44") is too big. Does QT has the method to make it.

            SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #5

            @jinming so those are in facts data unrelated to the headers above them.

            You might be able to do something with a custom QStyledItemDelegate

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

            J 1 Reply Last reply
            0
            • J jinming

              @SGaist Hi, I want to make a UI to display signal which is decoded by CAN data, like the below picture shows.

              treeview_span_explain.png
              It has the header "Time | Chn | ID | Name | ...." like QTreeView header, but the children has some difference, example, children item "EngTemp 86 degC 44" has the space between column "Time | Chn | ID | Name", I think this is suitable, because the information("EngTemp 86 degC 44") is too big. Does QT has the method to make it.

              M Offline
              M Offline
              mpergand
              wrote on last edited by
              #6

              @jinming
              I'd use the last data column for that as it can expand to the right border.
              You can set the tree position to this last colum as i'm doing here;

              1 Reply Last reply
              0
              • SGaistS SGaist

                @jinming so those are in facts data unrelated to the headers above them.

                You might be able to do something with a custom QStyledItemDelegate

                J Offline
                J Offline
                jinming
                wrote on last edited by
                #7

                @SGaist I read the qt example "Qt\Examples\Qt-6.5.1\widgets\itemviews\stardelegate". It uses StarDelegate which subclass QStyledItemDelegate, but the staritem size is controled by header. How a custom QStyledItemDelegate can expanding the item size that dones't control by header?

                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