Active Topics

 


Reply
Thread Tools
Posts: 662 | Thanked: 653 times | Joined on Feb 2010
#1
Essentially, as the title states. I wish to access the text data provided by the selected delegate and insert it into a text field. I have searched but am unable to return any results. I'm using an XMLListModel as the model and ListView to display the data.

Any help would be greatly appreciated.

Thanks
 
Posts: 724 | Thanked: 1,255 times | Joined on Nov 2007 @ Cambridge, UK
#2
Originally Posted by Reffyyyy View Post
Essentially, as the title states. I wish to access the text data provided by the selected delegate and insert it into a text field. I have searched but am unable to return any results. I'm using an XMLListModel as the model and ListView to display the data.

Any help would be greatly appreciated.

Thanks
An example of your source would be of great help y'know
 

The Following User Says Thank You to tswindell For This Useful Post:
Posts: 650 | Thanked: 619 times | Joined on Nov 2009
#3
Hi there, I had the same question a few weeks earlier. This is what I did:

Code:
// posView is a ListView element
posView.model.get(posView.currentIndex).quoteAsk
Remember, the currentIndex is not automatically updated and you need to assign it manually. For example, in the mouse area to receive the click, you do something like this:

Code:
            MouseArea {
                id: posMouseArea
                anchors.fill: background
                onClicked: {
                    posDelegateItem.ListView.view.currentIndex = index
                }
            }
The 'index' variable comes from Item element that is inherited by ListView.

There are other ways, but this one works for me so I simply use it. I couldn't get the currentItem property in the list view to work, though. You can read this for more info.
http://developer.qt.nokia.com/forums/viewthread/2981

(By the way, I found developer.qt.nokia.com super useful for QT-specific questions.)

Last edited by sony123; 2011-06-12 at 22:52.
 

The Following User Says Thank You to sony123 For This Useful Post:
Posts: 1,048 | Thanked: 979 times | Joined on Mar 2008 @ SF Bay Area
#4
In the delegate, in the MouseArea.onClicked, you set the value of a variable outside the delegate.

Code:
Text {
  id: outsideText
  text: "Default text"
}

ListView {
  delegate: Item {
    MouseArea {
      anchors.fill: parent
      onClicked: outsideText.text = text
  }
}
__________________
qgvdial: Google Voice client. All downloads
qgvtp: Phone integration for the n900 that dials out and sends texts using qgvdial.
mosquitto: message broker that implements the MQ Telemetry Transport protocol version 3.
qgvnotify: Google voice and contacts notifier for diablo and maemo.

If you want to thank me, click the Thanks button.
If you'd like to thank my applications, vote to move them to extras.
 

The Following 2 Users Say Thank You to uvatbc For This Useful Post:
Posts: 662 | Thanked: 653 times | Joined on Feb 2010
#5
Thanks for all your replies.

@uvatbc

Can't believe I didn't think of that, I'm an idiot. Been a bit of a long day, I guess.

Thanks a lot, guys.
 
Reply


 
Forum Jump


All times are GMT. The time now is 11:38.