QTableView selection behavior
-
wrote on 13 Mar 2019, 17:53 last edited by Anton Shelenkov
-
Hi all, how i can set selection behavior for QTableView like in Windows for files in folder when shift button is pressed?
I found this:
view->setSelectionBehavior(QAbstractItemView::SelectRows);but it can to change only for whole row/column selection behavior.
Now:
I need:
Thanks.!
wrote on 13 Mar 2019, 18:32 last edited by JonB@Anton-Shelenkov
I'm afraid I don't get exactly what your example is showing, but look atsetSelectionMode(QAbstractItemView::SelectionMode mode)
, https://doc.qt.io/qt-5/qabstractitemview.html#SelectionMode-enum.QAbstractItemView::ContiguousSelection
orQAbstractItemView::ExtendedSelection
are what you are looking for? -
@JonB said in QTableView selection behavior:
QAbstractItemView::ExtendedSelection
My money is on that one :)
-
This post is deleted!
-
@Anton-Shelenkov
I'm afraid I don't get exactly what your example is showing, but look atsetSelectionMode(QAbstractItemView::SelectionMode mode)
, https://doc.qt.io/qt-5/qabstractitemview.html#SelectionMode-enum.QAbstractItemView::ContiguousSelection
orQAbstractItemView::ExtendedSelection
are what you are looking for?wrote on 14 Mar 2019, 10:00 last edited by@Jon I tried that, it's not what i need. I think with pix it will be clearer what i want to.
-
@Jon I tried that, it's not what i need. I think with pix it will be clearer what i want to.
wrote on 14 Mar 2019, 11:03 last edited by JonB@Anton-Shelenkov
Per your selection picture now shown in your question (much better than your original textual description!)I think you certainly do not want
setSelectionBehavior(QAbstractItemView::SelectRows)
, that does what you show and by definition only selects whole rows. I think you must trysetSelectionBehavior(QAbstractItemView::SelectItems)
to get anything other than whole rows/columns selected. Then combine that withsetSelectionMode()
, passingQAbstractItemView::ContiguousSelection
or (probably)QAbstractItemView::ExtendedSelection
, and see how you go?
1/6