Results 1 to 4 of 4

Thread: QTableView disable multiselect while retain row select mode

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,343
    Qt products
    Qt5
    Platforms
    Windows
    Thanks
    318
    Thanked 872 Times in 859 Posts

    Default Re: QTableView disable multiselect while retain row select mode

    Yes, but now I cannot select a single cell.
    In this case, leave the selection mode for the table set to single cell selection. That will accomplish the 1 <-> 1 connection mode. Then, connect a slot to the row header's QHeaderView::sectionClicked() signal. In your slot, manually select all of the cells in the row. Do this by retrieving the selection model for the table (QTableView::selectionModel()), then create a QItemSelectionthat contains QModelIndex entries for all of the cells in the row, and finally calling QItemSelectionModel::select() with this QItemSelection. Calling select() will result in the selectionChanged() signal being emitted by the QItemSelectionModel, so you should be able to use the same slot to handle this as you do the single cell select.

    Note that you can't simply call QTableView::selectRow() because your selection mode allows only single cell selection.

  2. The following user says thank you to d_stranz for this useful post:

    MarkoSan (21st August 2014)

Similar Threads

  1. Replies: 2
    Last Post: 19th March 2012, 15:04
  2. Select First Row as default in QTableView ?
    By hohoanganh205 in forum Newbie
    Replies: 6
    Last Post: 22nd December 2011, 09:47
  3. QTableView select a whole row?
    By qlands in forum Qt Programming
    Replies: 1
    Last Post: 22nd August 2011, 12:22
  4. How select next row in QTableView
    By estanisgeyer in forum Qt Programming
    Replies: 8
    Last Post: 17th June 2009, 21:02
  5. How to select a cell in a QTableView
    By JeanC in forum Qt Programming
    Replies: 6
    Last Post: 6th February 2008, 14:20

Tags for this Thread

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.