Results 1 to 4 of 4

Thread: QTableView disable multiselect while retain row select mode

  1. #1
    Join Date
    Jan 2006
    Location
    Ljubljana
    Posts
    687
    Thanks
    111
    Thanked 4 Times in 4 Posts
    Qt products
    Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Android

    Question QTableView disable multiselect while retain row select mode

    Dear Sirs and Madams!

    Is it possible to disable cell multiselect in QHeaderView while retaining row select mode and if it is, how? If it is not, are there some ideas how to at least try to achieve something similar?

    Sincerely,
    Marko
    Qt 5.3 Opensource & Creator 3.1.2

  2. #2
    Join Date
    Apr 2012
    Location
    India.
    Posts
    88
    Thanked 8 Times in 8 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QTableView disable multiselect while retain row select mode

    Please read about QAbstractItemView::SelectRows, it will solve your problem.

  3. The following user says thank you to Rajesh.Rathod for this useful post:

    MarkoSan (17th August 2014)

  4. #3
    Join Date
    Jan 2006
    Location
    Ljubljana
    Posts
    687
    Thanks
    111
    Thanked 4 Times in 4 Posts
    Qt products
    Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: QTableView disable multiselect while retain row select mode

    Quote Originally Posted by Rajesh.Rathod View Post
    Please read about QAbstractItemView::SelectRows, it will solve your problem.
    Yes, but now I cannot select a single cell. I have following situation:

    I have a matrix of digital inputs and digital outputs. The matrix itself is subclassed QTableView, which has two subclassed QHeaderViews, vertical one for digital inputs and horizontal one for digital outputs. Now, if I click on single cell in matrix, I connect signal (electrical, not Qt one) with indexed input and ouput. If I select row, I connect one input to all outputs. And I MUST disable the option of column select, since connecting all digital inputs to one digital ouput present a problem, the user MUST not be able to do that. I've managed to disable column selection, but I cannot enforce the option of selection of single cell and if user prefers, to connect one input to all ouputs - row selection mode. How do I do that?

    Sincerely,
    Marko
    Qt 5.3 Opensource & Creator 3.1.2

  5. #4
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    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.

  6. 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, 14:04
  2. Select First Row as default in QTableView ?
    By hohoanganh205 in forum Newbie
    Replies: 6
    Last Post: 22nd December 2011, 08:47
  3. QTableView select a whole row?
    By qlands in forum Qt Programming
    Replies: 1
    Last Post: 22nd August 2011, 11:22
  4. How select next row in QTableView
    By estanisgeyer in forum Qt Programming
    Replies: 8
    Last Post: 17th June 2009, 20:02
  5. How to select a cell in a QTableView
    By JeanC in forum Qt Programming
    Replies: 6
    Last Post: 6th February 2008, 13: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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.