Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Populate QStandardItemModel item to QML
Qt 6.11 is out! See what's new in the release blog

Populate QStandardItemModel item to QML

Scheduled Pinned Locked Moved Unsolved General and Desktop
1 Posts 1 Posters 309 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    PavloPonomarov
    wrote on last edited by
    #1

    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*)

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved