[PyKDE] QListBox selectedItem()
    Greg Fortune 
    lists at gregfortune.com
       
    Mon Sep  1 18:21:01 BST 2003
    
    
  
The code works fine over here.  If you want to know what index is selected 
rather than what item is selected, call list.currentItem() which returns an 
int index number.  
If it says AttributeError, you either have an outdated version of PyQt (which 
you do) or an outdated version of Qt (which I have no idea about...)  Note 
that Qt 3.0 does not support selectedItem()...  If you aren't going to update 
your distros Qt version, make sure you use the correct version of the docs.  
Also note that list.currentItem() *is* supported in 3.0.
Greg Fortune
Fortune Solutions
On Monday 01 September 2003 12:06 am, Derek Fountain wrote:
> Is the QListBox selectedItem() method implemented? At the risk of looking a
> complete newbie, which I am, why does this:
>
> #!/usr/bin/python
>
> import sys
> from qt import *
>
> app=QApplication(sys.argv)
>
> list=QListBox()
> list.insertItem("Item 1")
> list.insertItem("Item 2")
> list.insertItem("Item 3")
>
> list.setSelected( 1, True )
> print list.selectedItem()
>
> app.setMainWidget(list)
> list.show()
> app.exec_loop()
>
> spit out this error:
> >./listbox_test.py
>
> Traceback (most recent call last):
>   File "./listbox_test.py", line 14, in ?
>     print list.selectedItem()
> AttributeError: selectedItem
>
> I'm running 3.3.2 on SuSE-8.1. That's a bit old these days, but surely
> something this basic should work if I was doing it right?
    
    
More information about the PyQt
mailing list