[Kde-bindings] QComboBox and QListBoxItem

Imobach González Sosa imobachgs at step.es
Sat Apr 3 16:36:28 UTC 2004


El Sábado 03 Abril 2004 13:51, Richard Dale escribió:
> I've had a look for examples of Qt::ComboBox, and the tictac one creates a
> combo box like this:
>
>                 # Create the combo box for deciding who should start
>                 # and connect its clicked() signals to the buttonClicked()
> slot @whoStarts = Qt::ComboBox.new(self)
>                 @whoStarts.insertItem('Computer starts')
>                 @whoStarts.insertItem('Human starts')
>                 l.addWidget(@whoStarts);
>
> So it doesn't create a seperate Qt::ListBoxItems like you do, but adds the
> list of things directly to the ComboBox with the insertItem() method.

Yes, that's right. But I forgot to mention in my post that I need to use 
ListBoxItems. Why? I need a value associated to each item of the combo, just 
like 'value' when using the tag <SELECT> in HTML. Do you know?

So, I thought that I could create a new class which inherited from ListBoxItem 
(let's call ListBoxItemExtended), adding this value. Then, putting some 
ListBoxItemExtended objects into a QListBox and getting this list into de 
QComboBox could do the trick.

>    @combo = Qt::ComboBox.new(false, centralWidget(), "@combo")
>    @combo.setGeometry( Qt::Rect.new(20, 59, 105, 33) )
>    @combo.insertItem("oranges")
>
> Alternatively, I think Qt::ComboBox.setListBox() resets everything, so you
> might need to do that first rather than last, and it might work.

Yes, I tried that too but it didn't work.

Thank you for your time and your help.

-- 
(o_.'   Imobach González Sosa   imobachgs at softhome.net
//\c{}  imobachgs at step.es       a2419 at dis.ulpgc.es
V__)_   imodev at softhome.net     osoh en jabber.at y jabber.org
        Usuario Linux #201634
Debian GNU/Linux `Sarge' con núcleo 2.6.4 sobre Intel Pentium 4

La existencia está tejida de un material de mala calidad que se encoge con el
uso.
		-- Rosa Montero. (1951-). 

-- 
Este mensaje ha sido analizado por STEP On Line
en busca de virus y otros contenidos peligrosos,
y se considera que está limpio. 902 10 18 43




More information about the Kde-bindings mailing list