Manoj
Manoj

Reputation: 971

Widgets auto positioning PyQt4

I have a layout in a class inherited from QtGui.QWidget window. Lets say I have three labels and a button , and when I click on a button , one of the Labels disappear. This spoils my QtGui.QWidget because the other two labels automatically resize. I wouldn't want that to happen. I want my labels to be placed as before , with only the third label disappearing. Any tips?

Simplified version of my code:

class a(QtGui.QWidget):
    def __init__(self):
        //Everything needed is done
        self.UI()

    def UI(self):
        layout = QtGui.QGridLayout(self)
        self.label1 = QtGui.QLabel('Label1')
        label2 = QtGui.QLabel('Label2')
        label3 = QtGui.QLabel('Label3')
        layout.addWidget(self.label1 , 0 , 0)
        layout.addWidget(label2 , 1 , 0) 
        layout.addWidget(label3 , 2 , 0)
        button = QtGui.QPushButton('Hide')
        button.clicked.connect(fun)

    def fun(self):
        self.label1.hide()

Upvotes: 0

Views: 90

Answers (1)

warvariuc
warvariuc

Reputation: 59574

You can place label1 widget inside a QFrame with no frame.

Upvotes: 1

Related Questions