Results 1 to 3 of 3

Thread: Layout, widgets and resize questions

  1. #1
    Join Date
    May 2009
    Posts
    52
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Layout, widgets and resize questions

    Hello,

    I have 2 little questions, maybe silly ones:

    I have a widget to which I attach a layout. Then I add lots of buttons & co to the layout.

    First question:

    How can I make the parent widget resize depending on the widgets I add or remove from the layout? I managed to make it grow, but removing widgets from the layout will not make the parent widget shrink. In the end I did it by resizing it myself, but I wonder if there isn't a smarter idea

    Second question:

    After adding the widgets on the layout, when will the geometry of the widget be updated so I can get the correct height by using widget.height()? After all kind of trials I managed to do that only after calling widget.setVisible(true). It is possible to get the height without that call?

    Thank you

  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: Layout, widgets and resize questions

    Hi,

    First of all I wonder why you want to remove your widget? I mean if you want your regarding widget to shrink itself via a widget removal, doesn't it break down the layout of your other widgets, windows, frames etc.

  3. #3
    Join Date
    May 2009
    Posts
    52
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Layout, widgets and resize questions

    No, it doesn't. I have a scroll area and the widget we're talking about is the widget set to the scroll area. Something like this:

    Qt Code:
    1. QWidget* theWidget = new QWidget();
    2. QVBoxLayou* theLayout = new QVBoxLayout(theWidget);
    3. theLayout->addWidget(...)
    4. theLayout->addWidget(...)
    5. theLayout->addWidget(...)
    6.  
    7. sc->setWidget(theWidget);
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Resize widget force layout resizing
    By ^NyAw^ in forum Qt Programming
    Replies: 17
    Last Post: 11th February 2009, 12:27
  2. Resize button when using layout
    By Macok in forum Qt Tools
    Replies: 3
    Last Post: 26th January 2009, 01:31
  3. Qidget height resize if child widgets invisible
    By visor_ua in forum Qt Programming
    Replies: 1
    Last Post: 27th April 2008, 12:27

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.