PyQt4: Hide widget and resize window

Posted by masterLoki on Stack Overflow See other posts from Stack Overflow or by masterLoki
Published on 2010-02-19T02:28:38Z Indexed on 2010/04/30 1:07 UTC
Read the original article Hit count: 405

Filed under:
|
|

Hi everyone:

I'm working with several widgets but the solution just won't come out. What I have is a series of buttons in series of QHBoxLayouts. Some buttons are hidden by default, but they will appear when needed. To solve space issues, all buttons have a minimum and maximum size so they always look well packed. Also I have a QTextEdit, visible by default, which is in a QVBoxLayout with the QHBoxLayout that hold the buttons

So the problem is this: When I hide the QTextEdit and show the other buttons, the window won't resize. After searching I found that using self.ui.layout().setSizeConstraint(QtGui.QLayout.SetFixedSize) will do the trick, but the problem is that it takes the maximum size from all widgets, therefore I end a huge window. Doing self.ui.layout().setSizeConstraint(QtGui.QLayout.SetMinAndMaxSize) won't resize the window

I already tried using self.ui.resize(0,0), and when doing a self.ui.layout().update() I got False (which I find odd, http://doc.trolltech.com/4.6/qlayout.html#activate), and also tried to override sizeHint() but it keeps using the max size for all widgets.

Is there a way to resize the window and while taking care of the min and max size of a widget?

Thanks in advance

© Stack Overflow or respective owner

Related posts about python

Related posts about pyqt4