PDA

View Full Version : QComboBox does not update



Cruz
19th February 2009, 14:27
Hi.

I have a QComboBox on my gui that I use to select a string from a given set of options. When I click on it the dropdown appears, I make my choice and then the dropdown closes again, but it's still the default value that is displayed. The combo box is connected to a slot, so I know that the choice was made correctly. Only when I move the mouse over the combo it finally gets updated and shows the last choice made.

I also tried connecting it to its own update slot



connect(ui.portComboBox, SIGNAL(currentIndexChanged(const QString)), ui.portComboBox, SLOT(update()));


to no avail.

Should I program something that automatically moves the mouse over the combo when a choice was made or what? :)

talk2amulya
19th February 2009, 14:33
could u show some more code related to this?

Cruz
19th February 2009, 14:56
Not really. I created the QComboBox in Designer. I checked the properties, there is nothing related to how the combo box is updated. Other than that, I just take the reference from ui and connect the combo to something:



connect(ui.portComboBox, SIGNAL(currentIndexChanged(const QString)), &robotInterface, SLOT(setPortName(const QString)));


That's how I see that the selection was successfully made.

spirit
19th February 2009, 15:04
you need to populate combobox by yourself or set a model which will take care about updating combobox.

Lykurg
19th February 2009, 15:06
For a better understanding. You have a QComboBox with values 1 (default), 2, 3, 4, 5, 6, 7, 8.... Use case:

1 is shown
-> you select 4
1 is still shown (but 4 is "emitted")
-> mouse over
4 is shown
-> you select 6
??? what is shown 4 or 1 (the default)

Is this behavior also if you use the preview function in designer?

Cruz
19th February 2009, 15:21
If you select 6, 4 is still shown. It keeps the old selection until you move over it with the mouse and then it refreshes.

The Designer preview does it just like it should. Well it did while I had the values hardcoded in the ui file. Now I changed it according to jpn's suggestion like this:



ui.portComboBox->addItems(QStringList() << "COM1" << "COM2" << "COM3" << "COM4");


But it still shows exactly the same behavious. I have to create a model for this little thing now? Argh.

Lykurg
19th February 2009, 15:28
I guess if it works in the designer and in your application not, you must do something - what ever - in your application which is blocking the normal update of the combobox...:eek:

Cruz
19th February 2009, 15:36
How could that possibly be? There is nothing related to this combo, other than its signal being connected to the slot of an object. Nothing is accessing or changing the combo in any way. Other inputs in the same widget, like a QTextEdit and some QLineEdits update perfectly fine.

I use the Eclipse Integration of Designer and closed the Property Editor by accident. How do I get it back?

Lykurg
19th February 2009, 18:56
How could that possibly be? There is nothing related to this combo, other than its signal being connected to the slot of an object. Nothing is accessing or changing the combo in any way. Other inputs in the same widget, like a QTextEdit and some QLineEdits update perfectly fine.


Don't ask me ;)


I use the Eclipse Integration of Designer and closed the Property Editor by accident. How do I get it back?

Window -> Show View -> Others :: Qt -> Qt C++ Property Editor :)