PDA

View Full Version : My first combobox does not react to the mouse



feraudyh
10th December 2013, 21:14
Hi,
I am using QTCreator and Designer to create a Window, into which I placed a combo box. I added 21 items.
The count property is 21, I checked it.
Unfortunately, when I run the program and click on the combobox, nothing happens: no drop down behaviour.
I've been scouring the official doc, and I cannot see a hint of why this might be.
yours truly

ChrisW67
10th December 2013, 21:25
There is no reason this should be if the widget is enabled. If you think it is enabled (the default) then there is something you are not describing that we can only guess at.

feraudyh
11th December 2013, 09:25
OK, thanks, I should consider this as strange.

feraudyh
11th December 2013, 11:27
Now I think I know what was going on:
I had added a "drawing widget" to the layout of the window programmatically. I created it from a class derived from QLabel so as to draw on, with extra methods, then I added it to the layout programmatically.
I did not think that I could use widgets derived from classes with QtDesigner. I still dont know.
on the other hand the combo box was drawn with QtDesigner, with no consideration for the layout. Yes that's not respectful.
Probably the "drawing label" widget was taking up the whole screen and the combobox was being masked. Now I'm adding the combobox by program, but it appears to the side of the label, halfway between the top and the bottom of the window, which is not ideal. At least it is responding.

Radek
11th December 2013, 16:17
The combo box has signals which need to be connected somewhere. The signals which could interest you are activated() and currentIndexChanged(). Depending on the relation of the combo box to the rest of your UI, there could be some default connecting but it need not suit you. This might be the reason why the combo box reacts sometimes and it does not do other times.

Create signal handlers for the combo box, connect and place breaks in the handlers. Debug and see whether your handlers are called and whether the handlers do what they should do.

ChrisW67
11th December 2013, 20:02
I did not think that I could use widgets derived from classes with QtDesigner. I still dont know.

Look at the section "Using Custom Widgets with Qt Designer" or search for "promote" in the Qt Designer manual

For vertical placement of the combo box in its horizontal layout space have a look at the alignment options on the right-click context menu for the widget in Designer.

feraudyh
15th December 2013, 20:07
Thanks Chris, that's very useful.