Important: Please read the Qt Code of Conduct -

ListModel and item

  • My situation is a ListModel and some objects in it:

            ScrollView {
                id: scrollView1
                ListView {
                    id: listView;
                    model: listViewModel;
                    delegate: listViewDelegate;
            Component {
                id: listViewDelegate;
                QQShareObject {
            ListModel {
                id: listViewModel;

    How can I call a function into QQShareObject objects?
    I tried
    but does not work..
    I need to have the current value of my QQShareObject object.

  • Moderators


    Try this

    listView.currentIndex = 6 // or whatever
    console.log(listView.currentItem) // gives the item at 6th position

    You can then access its properties. For eg:


  • This post is deleted!

  • for (var count= 0; count< listView.count; count++) {
    listView.currentIndex= count

    is not a good solution. The line
    listView.currentIndex= count
    changes the current selected item.
    Is possible to have the value of each items without to change the item index?

  • Moderators

    @mrdebug then the other way to access delegate would be to use children
    For eg:


    view = id of ListView and myId is declared as Q_PROPERTY in QQShareObject

  • Perfect!

Log in to reply