Search code examples
python-3.xpyqtdesignerpyqt5

Pyqt5 designer - grid layout breaks when adding widget


First picture

Second picture

Please check the pictures I attached to this post.

I added 4 grid layouts to Form. I did grid lay out and I got 4 squares.

Then I added three push button widgets - up to here everything is fine(PIC 1) but when I added itemlistwidget(PIC 2), the whole thing broke up as you can see. Itemlistwidget would take most of the screen. Now my question is how to fix the ratios in Qt designer to have each widget the size for which grid layout was prepared. Thanks.


Solution

  • I think that situation happened because four widgets' sizePolices were different.

    Default sizePolicy of pushButton : h - Minimum, v - Fixed

    Default sizePolicy of listWidget : h - Expending, v - Expending

    read about sizePolicy detail : http://doc.qt.io/qt-5/qsizepolicy.html

    When I have to make fix ratio, use empty widget with same default size Polices