I have created several QGridLayout and put different labels and other widgets in these. As I choose an option in a QComboBox, I will hide all layouts but the one I have chosen, i.e. show different set of widgets for different options.

I have tried this:
Qt Code:
  1. test_layout = new QGridLayout();
  2. test_layout->setColumnStretch(0,1);
  3. test_labelOne = new QLabel("Angle");
  4. test_labelOne->setParent(test_layout);
  5. test_layout->addWidget(test_labelOne, 0, 1);
To copy to clipboard, switch view to plain text mode 

For then later traverse the test_layout->children() to set visibility on these children.

This gives me the compile-error:
ConfigureDlg.cpp:520: error: no matching function for call to âQLabel::setParent(QGridLayout*&)â
/usr/local/Trolltech/Qt-4.5.0-rc1/include/QtGui/qwidget.h:527: note: candidates are: void QWidget::setParent(QWidget*)
/usr/local/Trolltech/Qt-4.5.0-rc1/include/QtGui/qwidget.h:528: note: void QWidget::setParent(QWidget*, Qt::WindowFlags)

Any suggestions?

setParent(QObject*) is a function in QObject. and setParent(QWidget*) is a function in QWidget, but QWidget inherits QObject. Shouldn't it be available?

What I really try to accomplish is to have several set of layouts and hide and show these on demand to get a more clean code.