Solved Why does the child widget not resize when I call resize () on parent?
-
There is CurveWidgetDialog derived form QDialog and QWidget curveWidget as child (attached picture).
I call method resize() in constructor of CurveWidgetDialog, but child widget ()curveWidget doesn't change size (qDebug() outputs "QSize(100, 30)"). I use folowing code:
CurveWidgetDialog::CurveWidgetDialog(QWidget *parent) : QDialog(parent), ui(new Ui::CurveWidgetDialog) { ui->setupUi(this); //... resize(1000, 1000); qDebug() << ui->curveWidget->size(); //... }
what the hell?
-
@xruck
I assume the reason is: What size settings do you have on yourCurveWidget
which tell it you'd like it to occupy the full size of its parentQDialog
?Otherwise: It's just possible that resizing in the parent's constructor is too early for the child, though I don't think so.
-
Do you mean sizePolicy? -
Hi
Some layout calculation is postponed until widget is shown meaning
qDebug() << ui->curveWidget->size(); in constructor does not show the new size values.So does it visually also NOT use all the space ?
When CurveWidgetDialog is actually shown on screen. -
@mrjj
I create and show dialog in the main.cppint main(int argc, char *argv[]) { QApplication a(argc, argv); CurveWidgetDialog w; w.show(); return a.exec(); }
I suppose I need handle QWidget::showEvent() signal to recive size of the widget?
-
@xruck
Yes showEvent should give true size.
So it does use the actual space when shown, and its just the size reporting that is off ? -
@mrjj Yeah! Fantasstic answer!! Thank you very much!:) We close question [EDIT: Expletives removed --JKSH]