PDA

View Full Version : [QComboBox] (pre-)select no item. (solved)



lauranger
17th July 2006, 12:59
Hi,
Has anyone a link to what is the policy in QComboBox for setting
the preselection (the current selected item at showing time) ?
As I have two comboboxes that I fill in the same way

cbb->addItem("String", myInt), and I don't use setCurrentIndex.
I get the first combo pre-selecting the first item and
the second combo pre-selecting none.
What triggers the pre-selection ?
Thanks in advance.

Edit: it appears that, in fact, the second combo has its first line selected,
but as it is an empty line I thought it was not (selected).
So my question becomes (as I tried setCurrentIdx(-1)) :
how do I make a not editable combobox select no item ?

wysota
17th July 2006, 13:11
Always the first item is selected unless you change the selection using setCurrentIndex. For comboboxes where you can enter your own items (I think they are called "editable") none of the items are selected by default.

lauranger
17th July 2006, 13:16
Hi Wysota :)
As stated in my first post :

I don't use setCurrentIndex.
I get the first combo pre-selecting the first item and
the second combo pre-selecting none.
And after adding setCurrentIndex(-1) to the first combo,
I still have the first item selected in it.
I guess it is something related to the default button in
a dialog (I show those combo in a wizard dialog).
What could I do, cheaper than subclassing ?

wysota
17th July 2006, 13:22
Add an empty item at the beginning. Regular comboboxes don't allow a state where "no item" is selected. The selection has to be valid all the time.

lauranger
17th July 2006, 13:26
OK that makes sense to me. thanks.