I have a problem layouting a PyQt window. I'm using a grid layout with one big QGLWidget and many smaller control components below it. When subclassing the QGLWidget I'm using the following code:
class GLWidget(QtOpenGL.QGLWidget):
def __init__(self, parent=None):
self.parent = parent
QtOpenGL.QGLWidget.__init__(self, parent)
sizePol=QSizePolicy(QtGui.QSizePolicy.Preferred,QtGui.QSizePolicy.Preferred)
sizePol.setWidthForHeight(True)
self.setSizePolicy(sizePol)
def sizeHint(self):
return QSize(300,450)
def widthForHeight(self,height):
return int(height/1.5)
I create the lyout with the following code:
class MainWidget(QtGui.QWidget):
def __init__(self, parent = None):
super(MainWidget, self).__init__(parent)
self.ogl_widget = GLWidget(self)
grid = QtGui.QGridLayout()
grid.setSizeConstraint(QtGui.QLayout.SetMinimumSize)
grid.addWidget(self.ogl_widget, 0,0,1,6)
#add other control components
<add LineEdits and Labels>
<their size policy is vertical: fixed, horizontal: expanding>
However, there is no change in the size of the QGLWidget. It always fills the remaining space with the resulting arbitrary aspect ratio. What do I have to add / change to fix this issue?