Windows: Retrieve correct QWindow size with QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling)

  • Hi,

    when using QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling) the QWindow size can't be retrieved properly,
    leading to occasional 1pixel offsets to GetClientRect on windows.

    The issue here is that size() obviously can give an odd number, but the devicePixelRatio is 2.0 for example.
    This leads to an even number after multiplying them.

    But GetClientRect can be odd. Therefore we have to use and ifdef for windows and use the GetClientRect to achieve better results.

    I'd love to see a way to get the same numbers from something like QWindow::size() or QWindow::scaledSize()

    Best Regards,

Log in to reply