View Full Version : Shape changing under other tab using slider/spinbox

7th August 2007, 05:25
Hi there,

I just joined the site, I am pleased there are forums for Qt developers. I am sure I will glean much from these boards. Hopefully someone can point me in the right direction as this is the first time I have programmed using a GUI toolkit.

What I am trying to accomplish is a shape changing dialog. My main window and tab accepts input from the user via a spin box/slider that are connected together. Based on that value (linked between the spin box and slider) which is limited between 0-8, I need 0-8 groups of input boxes/labels to show on another tab within the program, depending of course on the previous input from the other tab.

I have the book C++ GUI Programming with Qt 4 but unfortunately the only shape shifting windows are only toggled via a boolean value. This is a little more complex. I understand the signals/slots/connections, but I am puzzled as to how to accomplish this with my little experience.

If anyone has suggestions or a link to an example I would appreciate it. If I did not present enough information about what I am trying to accomplish, please let me know. I appreciate your time.


7th August 2007, 13:00
I think "shape-changing" is a bit too much said.
You only have to connect QSpinBox::valueChanged or QAbstractSlider::sliderChanged to some slot that handles those 8 widget groups( maybe you can use QGroupBox? ).

What you have to do is: create and layout all group boxes and hide the las 7 of them( considering the initial slider value is 1 ).

Next, when the user drags the slider or changes the spin box value, in the slot connected the changed signal you have to show the corresponding groups( or all of them up until that value ).
If you create the layout(s) correctly, the tab widget will resize itself.


7th August 2007, 20:59
Thanks a ton Marcel. I got it working. Its ugly code but its working.