[Kde-bindings] QComboBox and QListBoxItem

Richard Dale Richard_Dale at tipitina.demon.co.uk
Sat Apr 3 12:51:55 UTC 2004


On Friday 02 April 2004 23:57, Imobach González Sosa wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Hi all,
>
> Well, maybe the solution is pretty simple, but I'm having a little problem
> when trying to get into a combo box some list box items (QListBoxItem). I'm
> sure that the problem is me ;-)
>
> I'm using Ruby, but I think that the procedure could be the same (the idea)
> using other languages.
>
> First of all, I create a QComboBox, a ListBox and a ListBoxItem. Then, I
> add some items to the ListBox and associates it to the ComboBox. Something
> like:
>
>   @combo = Qt::ComboBox.new(false, centralWidget(), "@combo")
>   @combo.setGeometry( Qt::Rect.new(20, 59, 105, 33) )
>
>   list  = Qt::ListBox.new(@combo)
>
>   item  = Qt::ListBoxItem.new
>   item.setText("oranges")
>
>   list.insertItem(item)
>   @combo.setListBox(list)
>
> Is it right? Well, I guess no, because I obtained a combo box which, when I
> click on it, shows only the begining of the list... well, it's difficult to
> explain. It's like if the list was cutted near the top, and no values
> appear.
>
> Ideas? Thank you all in advance.
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.

   @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.

-- Richard



More information about the Kde-bindings mailing list