Results 1 to 2 of 2

Thread: How do you get a child widget to resize with its parent?

  1. #1
    Join Date
    Aug 2016
    Posts
    1
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Windows

    Question How do you get a child widget to resize with its parent?

    I have two custom widgets: Graph and Paint, I want to overlay the Paint widget on the Graph widget.

    I've made Paint a child of Graph and I have a layout assigned to the MainWindow; This works like I want it to until I change the size of the main window, the Graph adjusts, but Paint does not (see Figure 1). If I add a layout to the parent Graph as well then Paint ends up in the corner and still doesn't stretch appropriately (see Figure 2).

    I've been looking around, but haven't been able to find out how to adjust this, I would prefer a method of fixing it in the designer if possible. Thank you!

    Figure 1:
    ss4.jpg

    Figure 2:
    ss5.jpg
    Last edited by Anduril28; 24th August 2016 at 16:50.

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,420
    Thanks
    37
    Thanked 1,545 Times in 1,495 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: How do you get a child widget to resize with its parent?

    If you have no layout, then you need to resize manually.

    If you have a layout, the widget needs to tell the layout that it can expand.
    See the widget's sizePolicy property.

    Cheers,
    _

Similar Threads

  1. How to resize parent widget when child widget is resized
    By ainne810329 in forum Qt Programming
    Replies: 4
    Last Post: 29th November 2011, 07:47
  2. Replies: 1
    Last Post: 11th March 2011, 19:34
  3. child widget resize to parent widget
    By bobFromAccounting in forum Newbie
    Replies: 10
    Last Post: 11th February 2011, 02:53
  4. Replies: 7
    Last Post: 14th January 2010, 08:47
  5. Infinite loop - resize parent from child
    By bitChanger in forum Qt Programming
    Replies: 3
    Last Post: 5th May 2006, 13:21

Tags for this Thread

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.