0

I am making GUI using Qt designer. The Qt designer can intuitively show the location and size of the GUI, so I chose it. However, when operating the code, the size of the GUI and qt designer is different. This also ruined the sizes of other widgets. I don't know for some reason.

Below is my simple code.

import sys
from PyQt5.QtWidgets import *
from PyQt5.QtCore import Qt
from PyQt5.uic import loadUi

class MyWindow(QWidget) :
    def __init__(self) :
        self.dlg = loadUi('a.ui')
        self.dlg.show()

app = QApplication(sys.argv)
myWin = MyWindow()
app.exec()

QT Designer enter image description here

GUI enter image description here

I searched several sites, but the cause was unknown. I thought it was a setup related issue, but I don't know the exact cause.

Albert Einstein
  • 7,472
  • 8
  • 36
  • 71
MIMMM
  • 1
  • There's some essential information missing. Have you defined the window size in QT designer? You can set a fixed size in the main window properties or when you create your main window in code. – Dschoni Jul 21 '23 at 06:58
  • You're using layout managers in the wrong way. The layout you've been dragging from the widget box must be put within a main layout manager in the container widget(s). Right click on an empty area of the groupbox and select an appropriate layout from the related menu, then add/drag the inner layouts within that layout. See the documentation about [using layouts in Qt Designer](https://doc.qt.io/qt-5/designer-layouts.html). Also, always check the object inspector icons: if you see that small red "forbidden" icon near a container widget, it means that you didn't set a layout for it. – musicamante Jul 21 '23 at 16:09

0 Answers0