PDA

View Full Version : resizing child window with parent window



sujan.dasmahapatra
8th May 2012, 09:17
Please give me some idea on resizing the child window. I have parent widget, when resizing this parent widget, I want all my other child widgets should also resize accordingly.

I have tried with QFormLayout, with formlayout, the widget’s size is changing, e.g a pushbutton is coming horizontally as long as the parent widget, although I am specifying a size for 100,25 width and height.

Please give me some suggestion. Check this snippet.



MainWindow::MainWindow(QWidget *parent):QMainWindow(parent)
{
setGeometry(0,0,600,400);
QPushButton *button = new QPushButton(“Add chart”, this);
button->setGeometry(5,5,100,25);
button->show();

QTextEdit *edit = new QTextEdit(this);
edit->setGeometry(5, 35, width()-10, height()-40);
edit->show();
}

This 2 controls are set on the widget, now when I resize to the full screen, the textedit size is not changing accordingly, please help what I can do for this. Thanks Sujan

ChrisW67
8th May 2012, 09:26
Use a layout.

sujan.dasmahapatra
8th May 2012, 10:02
MainWindow::MainWindow(QWidget *parent):QMainWindow(parent)
{
setGeometry(0,0,600,400);
QPushButton *button = new QPushButton(“Add chart”, this);
button->setGeometry(5,5,100,25);
button->show();

QTextEdit *edit = new QTextEdit(this);
edit->setGeometry(5, 35, width()-10, height()-40);
edit->show();

QFormLayout *formL = new QFormLayout(this);
formL->addWidget(edit);
setLayout(formL);

}


See I have added a form layout, with this my edit is not changing when I resize the mainwindow. Please help

amleto
8th May 2012, 20:02
oh god, another one that likes to cross post
http://www.qtforum.org/article/37896/resizing-child-window-with-parent-window.html