[PyKDE] Listbox returns dictionary key?

Gordon Tyler gordon at doxxx.net
Thu Aug 7 05:46:00 BST 2003


On August 6, 2003 11:31 pm, Peter Clark wrote:
> self.connect(self.listBox, SIGNAL("selected(int)"),
> self.printWhatWeSelected)
>
> returns '0' if I select cat, '1' for 'dog', etc. To get the dictionary
> value for that selection, I could do
>
> d[k[int]]
>
> but this requires that I pass both d and k to the respective function, or
> make them both global. Is it possible for the listbox to report the text of
> what was selected, so that I could just use the text as the key?

Looking at http://doc.trolltech.com/3.1/qlistbox.html, it seems you could use 
the "selected(const QString &)" signal.

> 	Also, what magic is required for changing the signal to "clicked()" rather
> than "selected()"? I tried both clicked() and clicked(int) but got an error
> saying:
>
> QObject::connect: No such signal QListBox::clicked(int)
> QObject::connect:  (sender name:   'listBox')
> QObject::connect:  (receiver name: 'unnamed')

Try the "clicked(QListBoxItem *)" signal.

Ciao,
Gordon




More information about the PyQt mailing list