How would I go about resizing the widget when the retry child is hidden so that it looks as in the first image? The main layout is a QVBoxLayout, the retry child is a widget
Here is a basic example which does auto-resize upon widget hide/show.
dialog.h file:
#ifndef DIALOG_H
#define DIALOG_H
#include
#include
class dialog : public QDialog
{
Q_OBJECT
public:
explicit dialog(QWidget *parent = 0)
{
vlayout.addWidget(&checkbox);
vlayout.addWidget(&label);
label.setText("Label");
setLayout(&vlayout);
this->layout()->setSizeConstraint(QLayout::SetFixedSize); // !!! This is the what makes it auto-resize
checkbox.setChecked(true);
connect(&checkbox,SIGNAL(toggled(bool)),&label,SLOT(setVisible(bool)));
}
private:
QVBoxLayout vlayout;
QCheckBox checkbox;
QLabel label;
};
#endif // DIALOG_H
and main.c
#include
#include "dialog.h"
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
dialog d;
d.show();
return a.exec();
}