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

QQuickWindow::grabWindow renders too small on macOS retina

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 6.3.2, 6.4.2, 6.5.3
    • Quick: SceneGraph
    • None
    • macOS

    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

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

        Activity

          People

            qt.team.graphics.and.multimedia Qt Graphics Team
            marcel.gotsch Marcel Gotsch
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes