Results 1 to 2 of 2

Thread: hiding a widget without rearrange layout

  1. #1
    Join Date
    May 2009
    Posts
    75
    Thanks
    5
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default hiding a widget without rearrange layout

    I have 3 widget in a QHBoxLayout; when one of these is hidden, the layout is rearranged as if there is only two widget.
    I need that the hidden widget is not shown but the layout is unchanged.
    how can I obtain this behaviour?

    thanks

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: hiding a widget without rearrange layout

    You have two possible solutions.

    One, easier is to subclass the widget and reimplement its paintEvent (and possibly some of the input events) and either call the base class implementation or not, depending on a state of some flag. If you don't call the base class implementation, you'll get an empty widget.

    The other solution (which is probably more sane) is to put the widget into a QStackedWidget and add another empty widget to the stack. You just have to make sure the empty widget is of the same size as the real one (and it's size has to be fixed). Then all you need to do to "hide" a widget is to flip the page on the stack.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. changing layout of a widget
    By mikro in forum Qt Programming
    Replies: 10
    Last Post: 4th August 2009, 20:21
  2. Replies: 1
    Last Post: 14th May 2009, 22:00
  3. Resize widget force layout resizing
    By ^NyAw^ in forum Qt Programming
    Replies: 17
    Last Post: 11th February 2009, 11:27
  4. Hide widget, but not change layout
    By dimaz in forum Qt Programming
    Replies: 3
    Last Post: 21st November 2008, 14:32
  5. resizing events of a custom widget in a layout
    By Rooster in forum Qt Programming
    Replies: 7
    Last Post: 16th February 2008, 10:52

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.