Results 1 to 4 of 4

Thread: [Solved] how to hide widget in boxlayout but reserve the empty space

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1

    Default [Solved] how to hide widget in boxlayout but reserve the empty space

    Hi

    I have a list of widgets inserted into a box layout. When one of the widget is hide(), the empty space will be taken by the rest of the widgets. Is there a way to let the layout keep this space? i don't want the widgets move position automatically. I know i can use a widget to wrap and only hide the child widget, but is there a simpler can do the trick?

    Thank you very much.
    Last edited by dogeye; 13th February 2013 at 01:53.

  2. #2
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: how to hide widget in boxlayout but reserve the empty space

    One simple and quick thing would be to install an event filter on a hidden widget and eat/filter the paint event when hidden
    When you know how to do it then you may do it wrong.
    When you don't know how to do it then it is not that you may do it wrong but you may not do it right.

  3. #3
    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: how to hide widget in boxlayout but reserve the empty space

    Other options:
    Replace the disappearing widget with a QStackedWidget containing that widget and a blank QWidget as pages. Hiding then becomes switching between the QStackedWidget pages.
    Override the disappearing widget's paintEvent() and make it paint or not based on a property.

  4. #4

    Default Re: how to hide widget in boxlayout but reserve the empty space

    Thank you very much for the help.

Similar Threads

  1. Leaving an empty space around a widget
    By moatilliatta in forum Qt Programming
    Replies: 1
    Last Post: 11th October 2010, 16:03
  2. reserve a space of a list
    By maider in forum Qt Programming
    Replies: 6
    Last Post: 27th November 2009, 10:25
  3. QTableView empty space or too little space.
    By davemar in forum Qt Programming
    Replies: 2
    Last Post: 16th October 2009, 16:00
  4. empty space in QGridLayout
    By eleanor in forum Qt Programming
    Replies: 1
    Last Post: 4th July 2008, 09:36
  5. QTableWidget click in empty space results in error?
    By Giel Peters in forum Qt Programming
    Replies: 4
    Last Post: 21st January 2006, 00:07

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
  •  
Qt is a trademark of The Qt Company.