[Development] Making ItemSelectionModel more useful

Alberto Mardegan mardy at users.sourceforge.net
Sat Feb 20 13:19:44 CET 2016


Hi all!
  Since Qt 5.5, the QItemSelectionModel class is exposed to QML as
ItemSelectionModel (in the QtQml.Models module):

http://doc.qt.io/qt-5/qml-qtqml-models-itemselectionmodel.html

Apart from having almost no documentation, this component seems to be
rather hard to use in QML: its methods work with QModelIndex (while all
the models I've ever used in QML just speak row numbers) or
QItemSelection, which I believe is not usable in QML at all (at least,
it's not documented as a QML component).

I understand that the reason for all of this is that QItemSelectionModel
is a class originally created for C++ consumption, and that the
QModelIndex makes a lot of sense there. However, I would argue that the
QML version is hardly usable.

As I see it, either this class gets a "model" property and methods which
operate on integers (row numbers), or QModelIndex and QItemSelection
need to become first class citizens in QML as well. I guess that having
Q_GADGET is already a huge step forward, but we should also have a
generic way to turn a model+rowNumber into a QModelIndex: maybe a global
method Qt.makeIndex(model, row), which would also work on all models
supported by the QML engine?

Are there any plans about this, or what would be the best way to address
this?

Ciao,
  Alberto




More information about the Development mailing list