Qt World Summit: Register Today!

[Solved] Mulitple selection in ListView

  • As far as I understand it multiple selection in a listview is not possible.
    Will it ever be possible or is the design of the QML listview such that it would never be?
    Is there any workaround strategy to have some sort of multiple selection?
    What would be the issues around such a strategy?


  • The design strategy around it is quite simple: add a selection state to your model.

  • Thanx for the answer

    I thought it would be something like that. It sort of blurs the lines a bit about the " ... UI in QML and business logic in C++ .. " If you use C++ based models. But that does not really bother me and .... I might even be wrong :).
    Some other issues are (on the desktop) is the "shift-click to select an range" action. Is it possible to filter out just the shift click in a mousearea of the delegate and letting the parent of the delegate catch the rest and handle it as usual?

  • I think the selection state is business logic, but the lines are of course blurry. It is just up to the GUI to on the one hand render, and on the other end manipulate that state.

    As to your second question: that's where things really become blurry :-) I don't have a ready-made answer to this one.

  • Thanx for the answers

    I am marking the thread solved but I still not sure how I would do mouse event handling on QML side without handling all of the mouse events that the list would have handled for me.

Log in to reply