Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-52276

[Win] Custom QCursor hotspot not set correctly when using a High DPI display and Qt::AA_EnableHighDpiScaling is set

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P3: Somewhat important
    • 5.6.1
    • 5.6.1
    • None
    • Tested on Windows 10
      Del XPS 13 laptop
    • e4e62496ac62deab0e8f6ae9f064cf153b31d2fa (qtbase/5.6, 7.4.2016, 5.6.1)

    Description

      When running on Windows using a high DPI display with QApplication::setAttribute(Qt::AA_EnableHighDpiScaling) in place, if you create a custom cursor using the QCursor overload that takes a QPixmap, and if you correctly set the hot spot of the cursor, the cursor that is actually used has its hot spot set in the wrong place.

      I've attached a simplified example project that can be used to reproduce the problem. You can select from two built in Qt cursors and a custom crosshair cursor. The sample application paints a small blue circle at the location of the mouse cursor. This circle should align with the hostpot of the cursor. For the arrow cursor, the hotspot is at the tip of the arrow. For the cross cursors, it is in the center of the cross.

      I've also attached an image that shows each of the 3 cursors with and without Qt::AA_EnableHighDpiScaling set with the application running on a laptop with only a High DPI monitor. The 6 images were taken with a mobile phone, so disregard the fact that the scaling is different and the image quality isn't great. The same machine and monitor was used for all images. As you can see, when Qt::AA_EnableHighDpiScaling is set and a custom cursor is used (image surrounded by red box), the expected hotspot of the cursor (the center of the cross) does not align with the actual hot spot (represented by the blue circle).

      I've tested this on Windows and Macintosh 10.10 and I only see the behavior on Windows. It's possible that this problem exists on platforms other than Windows.

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              kleint Friedemann Kleint
              aclight Adam Light
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes