Jul-13-2019, 11:47 AM
Another example is this:
from PyQt5 import QtWidgets app = QtWidgets.QApplication([]) window = QtWidgets.QWidget() window.setGeometry(50, 50, 500, 300) menu_bar = QtWidgets.QMenuBar(window) menu_bar.setGeometry(0, 0, 500, 22) size_policy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Fixed) menu_bar.setSizePolicy(size_policy) menu_bar.addMenu("File") menu_bar.addMenu("Edit") lay = QtWidgets.QHBoxLayout() lay.addWidget(menu_bar) window.setLayout(lay) window.show() app.exec()If we remove the QVBoxLayout the sizepolicy is not working. Strange!