QTableView selection behavior
-
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.!
-
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.!
@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?@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.
@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?