[PyKDE] Listbox returns dictionary key?
Peter Clark
peter-clark at bethel.edu
Thu Aug 7 06:16:01 BST 2003
On Wednesday 06 August 2003 10:44 pm, Gordon Tyler wrote:
> Looking at http://doc.trolltech.com/3.1/qlistbox.html, it seems you could
> use the "selected(const QString &)" signal.
Ah-ha! I actually tried that, but I made a mistake; on the analogy of
"selected(int)", I tried omitting the "QString &" part. So is it only safe to
omit "index"? The documentation has the following:
void selected ( int index )
void selected ( const QString & )
Yet valid PyQt calls are:
"selected(int)"
"selected(const QString &)"
See my confusion? (Note that my knowledge of C++ is almost zilch, so forgive
any errors of ignorance.)
> > 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.
Perfect, although the fact that it is really an instance, and not a string,
threw me off for a moment. It's easily fixed, however, by converting it to a
string:
def listBoxItemSelected( self, index ):
print d[str(index.text())]
Thanks!
:Peter
--
Oh what a tangled web they weave who try a new word to conceive!
More information about the PyQt
mailing list