PDA

View Full Version : Port inherited QScrollView which contains custom widgets to Qt4



Len
15th May 2008, 19:12
I'm in the process of a Qt 3 to Qt 4 port and ran into the following issue:
In Qt3 we're sublcassing from QScrollView and overriding the addChild, removeChild and drawContents methods in order to populate the Scroll View with custom widgets. These custom widgets are usually fairly simple consisting of a label and another widget (QLineEdit, QSpinBox, QRadioButtonGroup, etc.) The widgets on the custom widgets are laid out horizontally and then the custom widgets themselves are laid out vertically. It roughly looks something along these lines:

Label1 RadioButton1
Label2 LineEdit2
Label3 RadioButton3
...
etc.

Each pair of widgets above constitutes a custom widget itself

I am looking to preserve the same look and similar ability to call an addChild(QWidget * customWidget) in order to add or remove items to this container. I also need to be able to get back the number of custom widgets in the container and a way to iterate through the widgets.

How would I go about doing this without the Qt3 Support library in Qt4?

jpn
16th May 2008, 13:58
In Qt 4 you would construct and install a layout on a plain QWidget and set that widget inside the scroll area with QScrollArea::setWidget().

Len
16th May 2008, 14:39
In Qt 4 you would construct and install a layout on a plain QWidget and set that widget inside the scroll area with QScrollArea::setWidget().

Thank you. How would I go about getting the count of the number of widgets in the layout and subsequently getting an iterator for them?