The pyqt control changes adaptively with the window size

1. Add controls in the ui form as required and place their relative positions;
2. Right-click on the blank space of the ui form (don’t select any controls) -> Layout -> grid layout (horizontal layout, vertical layout, etc. Choose one)

 

When realizing the function of automatic scaling of the control with the size of the interface, I added a layout layout to the interface and found that the label can be very adaptive, but it is difficult for the listwidget to achieve what you want. For example, if you want the listwidget to occupy a specific width or height of the interface when it is initialized, it is always difficult to achieve. Later, it was discovered that a label can be added to the blank area of ​​the interface, so that the listwidget can be initialized with reference to the label position.

When modifying lineedit and textedit, it was found that they were just the opposite. The height of LineEdit was smaller when adaptive, and the height of TextEdit was larger when adaptive. You can select the appropriate edit control according to your needs.

Guess you like

Origin blog.csdn.net/whuzhang16/article/details/109384506