Let's say I want to populate a listbox with a list of dictionary keys:

        d = {'cat':'Fluffy', 'dog':'Wolfie'}
        k = d.keys()
        k.sort()
        <Create listbox, and populate it with the items in k>

At this point, I've got a listbox with two items:

cat
dog

Now, 

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?
        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')

        Thanks again for letting me pick your brains,
        :Peter

-- 
Oh what a tangled web they weave who try a new word to conceive!

_______________________________________________
PyKDE mailing list    [EMAIL PROTECTED]
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde

Reply via email to