PyQt5 - possible to recreate the application main window at runtime?
-
Hi, I have a PyQt application which runs on Linux with a dual-monitor setup. I can move the application between two screens, but one of them has a high DPI 4K resolution so the text/labels/icons appear very small.
After reading the documentation, I tried setting the
QT_SCALE_FACTOR
environment variable, and that works fine on my machine. With different values, the entire application window gets scaled up/down accordingly which is exactly what I want. However,QT_SCALE_FACTOR
seems to be only read once at startup, changing it at runtime has no effect. It's a bit annoying that I have to set this value before launching the app or do a complete restart.I wonder if Qt provides a way to dynamically zoom in/out the entire application main window at runtime. That would make life much easier. All that I want to change at runtime is the rendering aspect of things so that widgets are scaled up/down, ideally I can just reload/refresh the UI window without changing any application data.
I know many apps like VSCode support this feature because web technologies like Electron make it very easy to implement, but it seems to be much more complicated in Qt?
-
Hi,
Might not be the answer you are looking for but Qt 6 should have better handling for that use case.
-
@SGaist Thanks, that's really good to know as I'm thinking about upgrading to Qt 6. Any details about how Qt 6 will be able to handle this or are there examples or documentation I can read and follow?
-