Discussion Board

Results 1 to 2 of 2
  1. #1
    Registered User
    Join Date
    Jan 2010

    Question How to access ListView current item data?

    I want to access ListView current item data, but I haven't a clue how to do it. This is my code:

    Item {
        id: root
        width: parent.width
        property int selectedIndex: -1
        property alias model: itemList.model
        property alias count: itemList.count
        property alias currentIndex: itemList.currentIndex
        property alias currentItem: itemList.currentItem
        Component {
            id: defaultDelegate
            Item {
                id: delegateItem
                property bool selected: index == selectedIndex;
                MouseArea {
                    id: delegateMouseArea
                    anchors.fill: parent
                    onPressed: selectedIndex = index;
                    onClicked: console.debug("Name: " + name)
                Text {
                    id: itemText
                    text: name
        ListView {
            id: itemList
            anchors.fill: parent
            model: myModel
            delegate: defaultDelegate
            clip:  true
            focus: true        
    Here is my problem: The click works just find and I get the proper value, but when I try to automatically go to the next index/item, I cannot access the data value. How could I do that?

    The myModel is from a SQLite table using QSqlTableModel in C++.


  2. #2
    Super Contributor
    Join Date
    Oct 2007
    જુનાગઢ - India

    Re: How to access ListView current item data?

    Probably you will get text of listview item by calling myModel.get(index).name

Similar Threads

  1. how to get listview data from another qml page
    By web_tur in forum Nokia N9
    Replies: 5
    Last Post: 2011-09-14, 19:05
  2. ListView item removing problem
    By pippo2010 in forum [Archived] Qt Quick
    Replies: 0
    Last Post: 2011-02-25, 23:01
  3. How to get Listview selected item
    By amol_benare604 in forum Qt
    Replies: 1
    Last Post: 2010-11-18, 09:25
  4. How to get or set current item in CAnkForm?
    By somowo in forum Symbian
    Replies: 4
    Last Post: 2008-12-25, 10:32
  5. How to Disable Command Button and list item on Listview for S40 devices
    By iworktech_kiran in forum Mobile Java General
    Replies: 3
    Last Post: 2008-08-29, 17:29

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts