Qt Designer adaptive control window layout change problem

I do not know if anyone encountered this situation: that is, to create a new window in the Qt Designer, and then later add the control, in order to control together with the window becomes larger and larger, the need for a layout can for the entire window. However the layout preview Qt Designer is possible, and the like to Pycharm editor would not run, as shown below:
Here Insert Picture Description
Here Insert Picture Description
Here Insert Picture Description
It can be seen in the run Pycharm buttons are clustered together, but will not be as as in the preview window adaptive amplification. This is really very difficult to understand, it took to figure out the day is really about the new form. From the first map you can see the form's property is QWdiget, that is to say that the new Widget form controls, rather than the Main Window Main Window.
Here Insert Picture Description
Pycharm displayed in the window in the code below for Widget form, needs to be displayed in a main window, the code creates a main window, and in the overall layout is Qt Designer Widget form controls, the main window does not layout, it appears unsuccessful!

class MyMainWindow(QMainWindow, Ui_Form):
    def __init__(self):
        super(MyMainWindow, self).__init__()
        self.setupUi(self)


if __name__ == "__main__":
    app = QApplication(sys.argv)
    win = MyMainWindow()
    win.show()
    sys.exit(app.exec_())

If you want the buttons are displayed, you can add a line of code in the window class Ui_Form

self.gridLayout.setGeometry(QtCore.QRect(0, 0, 400, 300))

Width and height can be changed according to the situation, run the following figure, the buttons are displayed, but it does not follow an adaptive window is large, which I tried for a long time did not make things right in the code, I do not know how to solve, hope to have the god tell me in the comments mess!
Here Insert Picture Description
My solution is designed to create a new direct Main Window Main Window, then the overall layout, can achieve the desired results after running up! Pigment, is so simple and crude (mainly still do not know how to solve the mess in the code, ooo, ooo!)
Here Insert Picture Description

Published 17 original articles · won praise 3 · Views 1807

Guess you like

Origin blog.csdn.net/weixin_43350361/article/details/104815219