SunQuest
           Python Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPython Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
SlickEdit: Code in over 40 languages across 7 platforms. SlickEdit’s unmatched power, speed, and flexibility allows even the most accomplished developers to write better code faster. Download a free trial today!
  #1  
Old March 2nd, 2004, 12:46 PM
mattcronin57 mattcronin57 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Posts: 12 mattcronin57 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Determining the selected item in a QListView

i have got a listview that i want to use to change the display when a user selects an item from the listview. however, im having problems finding the exact syntax to use.

i thought that the following was the right way to go, but it doesn't print out the value i thought it should:

print w.listOptions.selectedItem()

outputs as: <qt.QListViewItem instance at 0x84f3e3c>

could someone please point me in the right direction.

Reply With Quote
  #2  
Old March 2nd, 2004, 07:29 PM
rebbit rebbit is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Posts: 84 rebbit User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 8 h 7 m
Reputation Power: 5
each item in the list is represented by an instance of the QListViewItem class. so you'll need to call a method of that class to see it's value. I can't remember the exact syntax as it's been a while since I did anything with PyQt, but using this:

print dir(w.listOptions.selectedItem())

will give you a list of all the attributes of that class. from there you should be able to find a method that does what you want. so selectedItem() does return the selected item, just that it's an instance of QListViewItem that you need to do further work with to get your data.

Last edited by rebbit : March 2nd, 2004 at 07:31 PM.

Reply With Quote
  #3  
Old March 3rd, 2004, 09:57 AM
mattcronin57 mattcronin57 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Posts: 12 mattcronin57 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
thanks for the help. this is the line that gets the text for the column specified in the brackets in the text() method:

w.listOptions.selectedItem().text(0)

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPython Programming > Determining the selected item in a QListView


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway