Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Populate QStandardItemModel item to QML



  • Hello. As a forword, everybody uses Qt models with QML objects that provide "model" property (like ListView, TableView etc.) that then delegates model item to QML objects through QQmlDMAbstractItemModelData.
    But what if I need only one item of my model in particular QML Object?
    Of course I was able to register my model to use it in QML with qmlRegisterType. Created an invokable method getIndex(int row, int col, QModelIndex index = QModelIndex()) and got a model index of an item inside QML. Last thing that left was to use itemFromIndex(const QModelIndex &) to get a pointer to the model item and probably the ability to use it similar as the delegate but instead the result in QML is QVariant(QStandardItem*)


Log in to reply