#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2004
    Posts
    12
    Rep 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.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2004
    Posts
    84
    Rep Power
    11
    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.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2004
    Posts
    12
    Rep 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)

IMN logo majestic logo threadwatch logo seochat tools logo