Discussion Board

Results 1 to 2 of 2
  1. #1
    Registered User Sasler's Avatar
    Join Date
    Jan 2010
    Posts
    272
    I want to access ListView current item data, but I haven't a clue how to do it. This is my code:

    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++.

    Cheers
    http://www.ic-mobile.com/

  2. #2
    Nokia Developer Champion savaj's Avatar
    Join Date
    Oct 2007
    Location
    જુનાગઢ - India
    Posts
    3,034
    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 C++
    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
  •  
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved