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

QScreen::grabWindow does not behave consistently across platforms

    XMLWordPrintable

Details

    • macOS, Windows

    Description

      Reproducer attached. One needs 2 monitors with one extending the other to see the problem.

      On Windows, it is going to take screenshots for each of the screens. And one can see "screen0.png" and "screen1.png" for the result, that both screens are properly captured, i.e. origin at top-left corner of each screen and size of each screen.

      On macOS, the screenshot for the secondary monitor looks weird. It captures with origin at top-level corner of primary screen but still the size of secondary screen. One has to do something like

      screen->grabWindow(0, screen->geometry().x(), screen->geometry().y(), screen->geometry().width(), screen->geometry().height());
      

      to compensate the offset of secondary screen w.r.t primary screen.

      Nevertheless, the seemingly correct behavior on Windows is said to be the one with bug. Because on both platforms the coordinate should be w.r.t primary screen. However, the solution on macOS, i.e.

      screen->grabWindow(0, screen->geometry().x(), screen->geometry().y(), screen->geometry().width(), screen->geometry().height());
      

      produces nonsense pixmap on Windows.

      Anyway, the inconsistency is troublesome. A workaround is to just use

      screen->grabWindow(0);
      

      and let Qt decides the rest by itself.

      Attachments

        Issue Links

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

          Activity

            People

              owolff Oliver Wolff
              luqiaochen Luqiao Chen
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There are no open Gerrit changes