PDA

View Full Version : QComboBox Signals and Slots Help



dvmorris
11th March 2007, 03:38
I would like to have a QComboBox control the display of options based on what is currently selected in the ComboBox. I am fairly new to Qt and I haven't really figured the whole signals/slots thing out yet.

I have a ComboBox with "Mode 1", "Mode 2", "Mode 3", etc... and for "Mode 1" I want three checkboxes to be displayed, and "Mode 2", I want a SpinBox, and so on...

Is the best way to do this by using the currentIndexChanged signal, and sending it to a custom slot that hides and shows the options I want to display for each combobox choice? I'm not really sure the best way to structure this, because in the end I will have many different comboBoxes where each choice will need a page of options displayed below it.

Does anyone have an example of how I could accomplish this? Thanks for the help,
dave

dvmorris
11th March 2007, 05:46
I just discovered the QStackedWidget reference. This looks like a great option. Sorry for the trouble. If anyone has a good example using QComboBox with QStackedWidget, I would love to see what all can be done with it. Thanks,
dave

wysota
11th March 2007, 10:13
Connect the currentIndexChanged signal from the combobox to setCurrentIndex slot in the stacked widget. I think this is enough for an example :)

dvmorris
11th March 2007, 16:05
yes, that worked perfectly. I just hadn't ever seen the QStackedWidget documentation before. Thanks for much for your help,
dave