QListView returns last item not current item



  • I have an implementation of QAbstractListItem to allow access to a C++ model from a database query, that part is okay, because i can access the model correctly in my QML,
    however, i have two QML files, one with a QListView, and one with a form,
    from the QListView, when a user selects an item and presses a button, the view changes to the form to allow editing, however, i am employing QSettings to store some variables from the model, this is where my issue is, when using keyboard keys i correctly get the respective listItem attributes, when i press the button, to set QSettings, the attributes of the last item in the QListView are saved... where am i going wrong.

    this is my code:

    the delegate for the listView:
    @
    Component {
    id: listDelegate
    FocusScope{
    id: scope
    x: delegateItem.x; y: delegateItem.y
    width: delegateItem.width; height: delegateItem.height
    Item {
    id: delegateItem
    width: listView.width; height: 25
    x: 5
    clip: true
    focus: true
    onFocusChanged: {
    child_main_picture.width = 189
    child_main_picture.height = 219
    globalsettings.currentChildThumb = child_main_picture.source = thumb
    globalsettings.currentChildID = id
    }

                Row {
                    anchors.verticalCenter: parent.verticalCenter
                    spacing: 5
    
                    Column {...}
                    Column {...}
                    Column {...}
                    Column {...}
                    Column {...}
                    Column {...}
                    Column {...}
                }
            }
        }
    }
    

    @

    the qml for the button to switch views
    @
    PushButton {
    onClicked: {
    globalsettings.creatingChild = false
    globalsettings.updatingChild = true
    globalsettings.deletingChild = false
    if(personal_handler.prefillForUpdate === true){
    globalsettings.fireChildShow = true
    }
    }
    }
    @


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.