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
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
Please read about QAbstractItemView::SelectRows, it will solve your problem.
MarkoSan (17th August 2014)
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
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.Yes, but now I cannot select a single cell.
Note that you can't simply call QTableView::selectRow() because your selection mode allows only single cell selection.
MarkoSan (21st August 2014)
Bookmarks