Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. PyQt5 - possible to recreate the application main window at runtime?
QtWS25 Last Chance

PyQt5 - possible to recreate the application main window at runtime?

Scheduled Pinned Locked Moved Solved Qt for Python
4 Posts 2 Posters 207 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    neo-mashiro
    wrote on last edited by
    #1

    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?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #4

      I meant it's achieved internally so you don't have to do anything special unless you are doing your own rendering.
      QScreen would be of interest.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      1
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #2

        Hi,

        Might not be the answer you are looking for but Qt 6 should have better handling for that use case.

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        0
        • N Offline
          N Offline
          neo-mashiro
          wrote on last edited by
          #3

          @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?

          1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #4

            I meant it's achieved internally so you don't have to do anything special unless you are doing your own rendering.
            QScreen would be of interest.

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            1
            • N neo-mashiro has marked this topic as solved on

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved