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. [SOLVED] QTableview with expandable rows
Forum Update on Monday, May 27th 2025

[SOLVED] QTableview with expandable rows

Scheduled Pinned Locked Moved General and Desktop
7 Posts 4 Posters 11.0k 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.
  • M Offline
    M Offline
    mohsen
    wrote on 28 Feb 2012, 13:45 last edited by
    #1

    Hi, I need to have rows with expandable icon (+) and child rows which have dedicated headers like below:

    @Column1 Column2 Column3
    -Row1
    Child Column1 Child Column2 Child Column3
    --------------- --------------- --------------
    Child Row1 Child Row 2 Child Row3
    ------------- ------------------ --------------
    +Row2 @

    Any help would be appreciated!

    1 Reply Last reply
    0
    • E Offline
      E Offline
      Eddy
      wrote on 28 Feb 2012, 14:06 last edited by
      #2

      did you look at "QTreeView":http://developer.qt.nokia.com/doc/qt-4.8/qtreeview.html

      Qt Certified Specialist
      www.edalsolutions.be

      1 Reply Last reply
      0
      • M Offline
        M Offline
        mohsen
        wrote on 28 Feb 2012, 14:11 last edited by
        #3

        does QTreeView able to have dedicated columns for child rows?

        1 Reply Last reply
        0
        • S Offline
          S Offline
          soroush
          wrote on 28 Feb 2012, 21:02 last edited by
          #4

          Use QTreeView with a QTableModel; if you need more control, I'll suggest to design a custom delegate , maybe a simple composite widget like kget's:
          !http://s1.picofile.com/file/7315852361/snapshot16.jpeg(kget)!

          1 Reply Last reply
          0
          • A Offline
            A Offline
            andre
            wrote on 29 Feb 2012, 06:43 last edited by
            #5

            Also interesting perhaps is "QTitanDataGrid":http://devmachines.com/products/qtitandatagrid-overview.html

            1 Reply Last reply
            0
            • M Offline
              M Offline
              mohsen
              wrote on 1 Mar 2012, 05:19 last edited by
              #6

              @Soroush: Thanks for your suggestion. I was looking for a simple way but the custom delegate appears to be the only solution.

              @Andre: Thank you Andre! I was already checked that but it's commercial. I'm looking for a free one.

              1 Reply Last reply
              0
              • M Offline
                M Offline
                mohsen
                wrote on 13 Mar 2012, 06:36 last edited by
                #7

                I've found the solution. It's so easy and simple. We may do that using QTreeWidget.
                @
                // Row 1
                QTreeWidgetItem *row1 = new QTreeWidgetItem(ui->treeWidget);
                row1->setText(0, "Row 1"); //Column 1
                row1->setText(1, "Data"); //Column 2

                // Row 2
                QTreeWidgetItem *row2 = new QTreeWidgetItem(ui->treeWidget);
                row2->setText(0, "Row 2"); //Column 1
                
                //Child row for Row1
                QTreeWidgetItem *row1_child = new QTreeWidgetItem(row1);
                
                //Custom widget for child row
                QPushButton *pb = new QPushButton("Custom Child", ui->treeWidget );
                
                //Set custom widget to the child row
                ui->treeWidget->setItemWidget(row1_child, 0, pb);
                row1_child->setFirstColumnSpanned(true);
                

                @

                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