[Development] Fwd: Making ItemSelectionModel more useful

Filippo Cucchetto filippocucchetto at gmail.com
Sat Feb 20 14:18:16 CET 2016


Hi Alberto,
i think that QModelIndex has been brought in for dealing with TreeViews
and hierachical item models.
To be honest AFAIK you can manipulate QModelIndexes from QML.
You can test for validity or obtaining its row or column and model.
The implementation should be here
<https://github.com/qtproject/qtdeclarative/blob/45bd04ba73bd3e71c070e5724535ba87f6771323/src/qml/types/qqmlmodelindexvaluetype_p.h>
Given that, i'm not totaly sold for a double interface (rows and indexes).
I prefear dropping support for using integers for rows/columns from the
components in QtQuickControls (TableView, ComboBox etc). This would
also morph the styleData.index from being a int to a QModelIndex.

F.


2016-02-20 13:19 GMT+01:00 Alberto Mardegan <mardy at users.sourceforge.net>:

> 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
>
> _______________________________________________
> Development mailing list
> Development at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/development
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/development/attachments/20160220/e3b9ab9a/attachment.html>


More information about the Development mailing list