PDA

View Full Version : Qt Designer Windows Form in PyQt5 differs from the Preview in Qt Designer



gussabina
1st September 2020, 05:27
Hello All:

I'm using Qt Designer to create a Windows Form which I save as window.ui and then use it from PyQt5. Problem is the Preview in Qt Designer and the "real" window differs substantially... I would expect the final GUI be pretty close as the one Qt Designer shows in the Preview...
In the following screenshot, the window at the left is the "real" one while the right shows the Preview from Qt Designer;

13532

This is the code I'm using to import the "window.ui" file;

class Window(QtWidgets.QMainWindow):
def __init__(self):
super(Window, self).__init__()
uic.loadUi("window.ui", self)



if __name__ == "__main__":
app = QtWidgets.QApplication([])
win = Window()
win.show()
sys.exit(app.exec())


Any idea why this happens? Should I configure something else?

Thanks in advance;
Gus

gussabina
1st September 2020, 17:01
Actually, I think Qt Designer is not showing the right size...Its window form is scaled out. My laptop screen is 1920 x 1080 pixels. In Qt Designer, the Form width is 466 and it is taking more than half the screen width, so it seems the Qt Designer is not properly scaling the Form correctly....
It looks like Qt Designer is running on a 800 x 600 screen, not at 1920 x 1080. Is there anything to setup here?

Check this screenshot;

13533

Thanks
Gus

Added after 27 minutes:

I just solve it! Just in case someone runs over the same problem, disabling the high DPI scaling option in Tools -> Options -> Environment solved the problem.

13534