Results 1 to 5 of 5

Thread: Widget does not resize correctly

  1. #1
    Join Date
    Mar 2010
    Location
    The Netherlands
    Posts
    7
    Thanks
    2
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Widget does not resize correctly

    Hello everybody.

    I have the following layout in my Widgets:

    Widget 1:
    A QWidget (named extWidget) and a Groupbox containing pushbuttons in a vertical layout. Groupbox has max height. QWidget fills the rest of the screen: sizePolicy(expanding,expanding).

    Widget 2:
    9 pushbuttons in a GridLayout.

    Now when the first Widget is created. I create the 2nd Widget with the extWidget as parent.

    Now when I run my code the 2nd widget gets displayed in the extWidget area of the 1st. So far so good.
    But the 2nd widget is displayed with its size as set at design time and when I resize the 1st widget, the 2nd does not change.

    How can I get my 2nd widget to alter its size to the available space of the extWidget area of the 1st?

    Qt Code:
    1. // Code from the constructor of the 1st widget
    2. m_ui->setupUi(this);
    3. // Create the 2nd Widget
    4. StdConfig = new unitconfigStd(m_ui->extWidget);
    5. StdConfig.show();
    To copy to clipboard, switch view to plain text mode 


    Thank you for your time,
    D
    Last edited by Demandred; 15th April 2010 at 09:20.
    0x2B || !0x2B // Hamlet

  2. #2
    Join Date
    Dec 2008
    Location
    Istanbul, TURKEY
    Posts
    537
    Thanks
    14
    Thanked 13 Times in 13 Posts
    Qt products
    Qt4
    Platforms
    Windows Android

    Default Re: Widget does not resize correctly

    look at size policy property of widgets

  3. The following user says thank you to zgulser for this useful post:

    Demandred (16th April 2010)

  4. #3
    Join Date
    Mar 2010
    Location
    The Netherlands
    Posts
    7
    Thanks
    2
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: Widget does not resize correctly

    Hi zgulser
    Thank you for your reply.

    In my opinion I tried all different settings, but the result remains the same. The widget does not resize at all.
    I will try to add my sources as a zip-file to this thread. Maybe somebody can take a look at what I'm doing and point me in the right direction.
    Attached Files Attached Files

  5. #4
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,543
    Thanks
    13
    Thanked 1,577 Times in 1,506 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Widget does not resize correctly

    What layout have you set on extWidget? Sounds like it is missing.

  6. The following user says thank you to ChrisW67 for this useful post:

    Demandred (16th April 2010)

  7. #5
    Join Date
    Mar 2010
    Location
    The Netherlands
    Posts
    7
    Thanks
    2
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: Widget does not resize correctly

    hmz. that could be the case. I cannot set the layout @ designtime (in Creator).
    So I guess I will have to do that @runtime after I added the child widget to extWidget?
    I'll try to figure this out... If I cannot get it to work I'll return to the forum again

    [edit]
    After some fumbling around with the layout(s) I got it to work.
    Thanks everybody for the input!

    Solution:
    I created the Config screen at runtime (extWidget as parent).
    After that I set the SizePolicy of the Config screen to [Expanding,Expanding] in code.
    (Don't know why I had to, but it is somehow required for the desired result.)
    Then I created a QVBoxLayout which has the extWidget as parent.
    I added the Config widget to the layout,
    and set the new created layout to the extWidget.
    [/edit]
    Last edited by Demandred; 16th April 2010 at 12:27.

Similar Threads

  1. proportional widget resize
    By momesana in forum Qt Programming
    Replies: 7
    Last Post: 15th December 2010, 03:22
  2. Resize Widget To Desktop Size
    By fruzzo in forum Qt Programming
    Replies: 6
    Last Post: 2nd October 2008, 15:29
  3. Replies: 5
    Last Post: 25th May 2008, 08:22
  4. Resize a Widget
    By sonu in forum Qt Programming
    Replies: 9
    Last Post: 29th October 2007, 07:06
  5. Custom Shape Widget (resize)
    By PiXeL16 in forum Qt Programming
    Replies: 7
    Last Post: 12th February 2007, 07:00

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.