Solved How to select a range with ItemSelectionModel?
-
The docs for
ItemSelectionModel
say you can pass aQItemSelection
toItemSelectionModel.select(selection, flags)
. Does anyone kn ow how this is possible? There is noItemSelection
type which would wrapQItemSelection
. The docs are silent on this.I am trying to implement shift-select to toggle a range in a
TableView
2.Thanks!
-
Hi,
Why not set the SelectionMode of your view to
QAbstractItemView::ExtendedSelection
? -
This is about the QML type and not the C++ type. Unless I’m misunderstanding you?
-
@patrickkidd said in How to select a range with ItemSelectionModel?:
This is about the QML type and not the C++ type. Unless I’m misunderstanding you?
Sorry, I misread your post.
Did you already saw this thread about that matter ?
-
@sgaist said in How to select a range with ItemSelectionModel?:
@patrickkidd said in How to select a range with ItemSelectionModel?:
This is about the QML type and not the C++ type. Unless I’m misunderstanding you?
Sorry, I misread your post.
Did you already saw this thread about that matter ?
That thread is about Controls 1 while my question pertains to Controls 2 and item models.
-
I've made an example 'on a knee', but it uses some cheats. Maybe someone can provide some better examples.
Example -
I also need multiselect functionality in my
GridView
. What I see, onlyTreeView
hasselection
property which can hold selection model. In my case, multiselect should be activated only when user holdCTRL
key in focusedGridView
, I'm trying to solve this withCheckDelegate
andnextCheckState
function callback -
@intruderexcluder said in How to select a range with ItemSelectionModel?:
I've made an example 'on a knee', but it uses some cheats. Maybe someone can provide some better examples.
ExampleI also am currently using a similar workaround where I have a C++
select(selectionModel, fromIndex, toIndex, SelectionFlags)
that makes the call for me.So then my original question is if it is possible to make the same call directly from Qml.