Skip to content
  • 0 Votes
    6 Posts
    3k Views
    S

    Well, my research checks out, but my solution was still wrong.

    The solution worked on my computer, but it was not right on the next computer.

    Turns out, it was a case of "did you try to turn it off an on again?": I didn't restart my computer after switching the primary monitor in Windows. This is the real solution!

  • 0 Votes
    2 Posts
    424 Views
    D

    The code to fix this problem was really unexpected and quite time consuming. The kicker is that QGuiApplication.devicePixelRatio() always returns 1.0 under Gnome, regardless of what scaling is actually set to. That means Gdk must be called to determine the scaling value.

    import gi gi.require_version('Gdk', '3.0') from gi.repository import Gdk def any_screen_scaled_gdk() -> bool: """ Detect if any of the screens on this system have scaling enabled. Uses GDK to do the querying. :return: True if found, else False """ try: display = Gdk.Display.get_default() except Exception: import logging logging.exception( 'An unexpected error occurred when querying the systems display parameters. Exception:' ) return False if display: try: for n in range(display.get_n_monitors()): monitor = display.get_monitor(n) if monitor.get_scale_factor() > 1: return True return False except AttributeError: # get_n_monitors() was introduced in gtk 3.22 try: screen = display.get_default_screen() for monitor in range(screen.get_n_monitors()): if screen.get_monitor_scale_factor(monitor) > 1: return True except Exception: import logging logging.exception('An unexpected error occurred when querying Gdk. Exception:') return False def any_screen_scaled_qt() -> bool: """ Detect if any of the screens on this system have scaling enabled. Call before QApplication is initialized. Uses temporary QGuiApplication. :return: True if found, else False """ app = QGuiApplication(sys.argv) return app.devicePixelRatio() > 1.0
  • 0 Votes
    24 Posts
    8k Views
    C

    Turns out there is a simple solution:

    app.setAttribute(Qt.AA_UseHighDpiPixmaps)
  • 0 Votes
    3 Posts
    2k Views
    James.EmertonJ

    I did some exploratory debugging and found that (on Windows 10) QWindowsStyle::drawPrimitive() is not being called to render checkboxes, but rather they are being drawn with DrawThemeBackgroundEx() from uxstyle.dll (which I would have expected to support High DPI correctly.)

    After looking at the screen shots attached to the ticket referenced above I discovered that I have a different sort of drawing problem; checkboxes are being render correctly, but at the same size (13px) regardless of device scaling.

    On Windows 7 checkboxes appear to render correctly with device scaling enabled.

  • 0 Votes
    3 Posts
    3k Views
    SGaistS

    Hi and welcome to devnet,

    I'd recommend posting this question to the Qt Creator mailing list. You'll find there Qt Creator's developers/maintainers. This forum is more user oriented.

  • 0 Votes
    1 Posts
    734 Views
    No one has replied