Results 1 to 1 of 1

Thread: QTableView & item grouping with another QTableWidget[solved]

  1. #1
    Join Date
    Jan 2009
    Posts
    47
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    6
    Thanked 1 Time in 1 Post

    Default QTableView & item grouping with another QTableWidget[solved]

    Hi all,

    I have a QTableView with a custom model that display
    Table 1
    Name Type
    a Type1
    b Type2
    c Type3
    d Type3
    e Type3
    now I have a need for item grouping, for example:
    Table 2
    Group Items Count
    Group 1 a, b 2
    Group 2 c, d, e 3

    next, I need
    1) the ability to highlight items in Table 1 when a row in Table 2 is selected. If "Group 1" is selected, then item # a and # b of Table 1 are selected/highlighted. I have a callback when a row in Table 2 is clicked as
    Qt Code:
    1. QItemSelection selection;
    2. QItemSelectionModel * selectionModel= m_ui->table1View->selectionModel();
    3. ...
    4. // looping through QModelIndex that are stored
    5. selection.select(modelIndex, modelIndex);
    6. // end of looping
    7. ...
    8. selectionModel->select(selection, QItemSelectionModel::SelectCurrent);
    9. ...
    10. m_ui->table1View->setSelectionModel(selectionModel);
    11. m_ui->table1View->setFocus();
    To copy to clipboard, switch view to plain text mode 
    but nothing is selected in Table1
    2) I will also need the reverse, highlight of corresponding group when an item in table 1 is selected
    Please help. Thanks in advance

    ----------
    i only stored the QModelIndexes for the first column only because I have select row policy on my table. In the selection.select(...) line above, I had to look up for the last QModelIndex on that row via modelIndex.sibling call and that solves my problem
    Last edited by ttvo; 22nd April 2010 at 15:46. Reason: solved

Similar Threads

  1. QTableWidget NW corner header item?
    By McKee in forum Qt Programming
    Replies: 9
    Last Post: 30th May 2012, 23:44
  2. QTableView Item Selection
    By johnmauer in forum Qt Programming
    Replies: 16
    Last Post: 25th January 2010, 22:50
  3. Grouping Widgets Together
    By joshuajcarson in forum Qt Programming
    Replies: 1
    Last Post: 21st October 2008, 20:17
  4. QTableWidget::item to Double?
    By Afflicted.d2 in forum Qt Programming
    Replies: 2
    Last Post: 30th October 2006, 06:23
  5. QTableWidget item checkable and combo?
    By darpan in forum Qt Programming
    Replies: 1
    Last Post: 10th October 2006, 07:12

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.