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. QListView returns last item not current item
Qt 6.11 is out! See what's new in the release blog

QListView returns last item not current item

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 710 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.
  • T Offline
    T Offline
    tharoldD
    wrote on last edited by
    #1

    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
    }
    }
    }
    @

    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