Results 1 to 4 of 4

Thread: resizing child window with parent window

  1. #1
    Join Date
    Feb 2009
    Posts
    189
    Thanks
    2

    Smile resizing child window with parent window

    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.

    Qt Code:
    1. MainWindow::MainWindow(QWidget *parent):QMainWindow(parent)
    2. {
    3. setGeometry(0,0,600,400);
    4. QPushButton *button = new QPushButton(“Add chart”, this);
    5. button->setGeometry(5,5,100,25);
    6. button->show();
    7.  
    8. QTextEdit *edit = new QTextEdit(this);
    9. edit->setGeometry(5, 35, width()-10, height()-40);
    10. edit->show();
    11. }
    To copy to clipboard, switch view to plain text mode 
    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

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: resizing child window with parent window

    Use a layout.

  3. #3
    Join Date
    Feb 2009
    Posts
    189
    Thanks
    2

    Default Re: resizing child window with parent window

    Qt Code:
    1. MainWindow::MainWindow(QWidget *parent):QMainWindow(parent)
    2. {
    3. setGeometry(0,0,600,400);
    4. QPushButton *button = new QPushButton(“Add chart”, this);
    5. button->setGeometry(5,5,100,25);
    6. button->show();
    7.  
    8. QTextEdit *edit = new QTextEdit(this);
    9. edit->setGeometry(5, 35, width()-10, height()-40);
    10. edit->show();
    11.  
    12. QFormLayout *formL = new QFormLayout(this);
    13. formL->addWidget(edit);
    14. setLayout(formL);
    15.  
    16. }
    To copy to clipboard, switch view to plain text mode 

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

  4. #4
    Join Date
    Sep 2011
    Posts
    1,241
    Thanks
    3
    Thanked 127 Times in 126 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: resizing child window with parent window

    oh god, another one that likes to cross post
    http://www.qtforum.org/article/37896...nt-window.html
    If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

Similar Threads

  1. Parent window over child
    By neolol in forum Qt Programming
    Replies: 4
    Last Post: 15th May 2009, 21:15
  2. Parent Child for window
    By febil in forum Qt Programming
    Replies: 6
    Last Post: 1st April 2009, 05:00
  3. connecting child to parent window...
    By sumit in forum Qt Programming
    Replies: 1
    Last Post: 19th October 2008, 21:28
  4. How to close parent window from child window?
    By montylee in forum Qt Programming
    Replies: 5
    Last Post: 14th October 2008, 11:40
  5. Replies: 11
    Last Post: 4th June 2008, 07:22

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.