Search code examples
pythonpyside

Window sized using sizeHint, but woud like it to still be adjustable by the user after


I am using Python and PySide to create a GUI with a dynamic amount of widgets. I am using sizeHint right now to calculate the size of the window. It works pretty well, but the window is a fixed size when generated. I would like the user to be able to be able to adjust the GUI window on a case by case basis after the sizeHint does the initial calculation. Thanks.

 #window.setMinimumWidth(1125)

 #window.setFixedWidth(740)

 #window.setMinimumHeight(800)

 #window.setFixedHeight(200)

 window.setFixedSize(grid_layout.sizeHint())

 window.setFixedWidth(3500)

 window.setAttribute(QtCore.Qt.WA_DeleteOnClose)

 window.show()

Solution

  • Do not set fixed size, just set geometry after show()

    window.show()
    height = grid_layout.sizeHint().height()
    width = 3500
    geometry = QtCore.QRect(window.pos(), QtCore.QSize(width, height))
    window.setGeometry(geometry)