example of QSizePolicy Maximum in PySide2

if you set the size policy property of widget to Maximum, the result of sizeHint() come to be maximum size of widget. it means that the size of widget cannot be larger than sizeHint().

from PySide2 import QtWidgets

app = QtWidgets.QApplication([])

window = QtWidgets.QWidget()
layout = QtWidgets.QHBoxLayout()
MaximumButton = QtWidgets.QPushButton("Maximum Widget")

MaximumButton.setSizePolicy(QtWidgets.QSizePolicy.Maximum , QtWidgets.QSizePolicy.Maximum )

layout.addWidget(MaximumButton)
window.setLayout(layout)
window.show()

app.exec_()




QPushButton's minimumSizeHint() function is implemented. so, even if we didn't set the minimum size, the size of button cannot be decreased more than first image.

and, when I increased the size of window, the size of button is not increased according to the size of window. because the size policy is Maximum that means the size of button cannot be larger than sizeHint(). as the result, the button's size of first image is same to second.




Comments

Popular posts from this blog

making menubar and menu on QML

QSizePolicy Fixed example in pyside2

let's start QML programming with PySide2