Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. ListView CurrentItem get underlying object
Forum Updated to NodeBB v4.3 + New Features

ListView CurrentItem get underlying object

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
3 Posts 2 Posters 594 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.
  • M Offline
    M Offline
    MartinD
    wrote on last edited by
    #1

    Hi,
    I display C++ object in ListView (model is QQmlListProperty). I can access individual objects in listview's delegate via model.modelData.

    How can I access C++ objects via currentItem property ofthe ListView?

    1 Reply Last reply
    0
    • ? Offline
      ? Offline
      A Former User
      wrote on last edited by
      #2

      Hi! Can you please show some code to clearify the matter?

      1 Reply Last reply
      0
      • M Offline
        M Offline
        MartinD
        wrote on last edited by MartinD
        #3
        class MyClass: public QObject {
          Q_OBJECT
          Q_PROPERTY(QQmlListProperty<MyType> myList READ myList NOTIFY myListChanged)
        
          QQmlListProperty<MyType> myList(void) {
            return QQmlListProperty<MyType>(this, myQList);
          }
        
          QList<MyType *> myQList;
        

        And QML:

                    GridView {
                        model: myList // see property myList in MyClass
                        onCurrentItemChanged: {
                             // here I want to access property of currently selected MyType object
                        }
                    }
        
        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