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

QQuickWindow::grabWindow renders too small on macOS retina

    XMLWordPrintable

Details

    • d96f61672 (dev), d88b17313 (6.10), e10fc5eda (6.9), f64bcade5 (tqtc/lts-6.8), 4aec9781b (tqtc/lts-6.5)

    Description

      Grabbing the contents of a window on macOS with device pixel ratio 2 results in an image with the correct physical size, but the rendered content is too small.

      #include <QtGui/QGuiApplication>
      #include <QtQuick/QQuickWindow>
      #include <QtQuick/QQuickItem>
      #include <QtQml/QQmlComponent>
      
      int main(int argc, char** argv){
          QGuiApplication app{argc, argv};
          QQuickWindow window;
          window.resize({200, 200});
      
          QQmlEngine qmlEngine;
          QQmlComponent component{&qmlEngine};          
          component.setData(QByteArrayLiteral("import QtQuick\nRectangle{ color: 'red' }"), {});
      
          auto* item = qobject_cast<QQuickItem*>(component.create());
          item->setParent(window.contentItem());
          item->setParentItem(window.contentItem());
          item->setSize({200, 200});
      
          window.grabWindow().save("qt6-test.png");
      } 

      Attachments

        Issue Links

          For Gerrit Dashboard: QTBUG-116675
          # Subject Branch Project Status CR V

          Activity

            People

              lagocs Laszlo Agocs
              marcel.gotsch Marcel Gotsch
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes