diff options
author | Thomas Hartmann <thomas.hartmann@qt.io> | 2020-11-10 16:45:59 +0100 |
---|---|---|
committer | Thomas Hartmann <thomas.hartmann@qt.io> | 2020-11-12 15:15:48 +0000 |
commit | 98c735be6e3335fd19a7fbd2a23b7938d69ecfe5 (patch) | |
tree | d185be9bbcb615edad79673d828cf460dfb5962d /share/qtcreator/qml/qmlpuppet/qml2puppet/instances/quickitemnodeinstance.cpp | |
parent | 3d767fcfe1ef2319acbd4b688bbedcaaf3cd80c3 (diff) |
QmlDesigner: Fix for high dpi and Qt 6
When grabbing the window we have to clip the window using
the root item size.
Depending on the window manager the window is resized.
Another issue is that when grabbing the window offscreen
the pixel ratio is always 1.
Before we assumed that the pixel ratio of all images
is the same for the host process as for the puppet.
This is not necessarily anymore and we have to set
and forward the correct pixel ratio.
Change-Id: I36b467291ab120f825119adea4ed7db10d34266d
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
Diffstat (limited to 'share/qtcreator/qml/qmlpuppet/qml2puppet/instances/quickitemnodeinstance.cpp')
-rw-r--r-- | share/qtcreator/qml/qmlpuppet/qml2puppet/instances/quickitemnodeinstance.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/quickitemnodeinstance.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/quickitemnodeinstance.cpp index bc91a47505..b400d8c2d2 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/quickitemnodeinstance.cpp +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/quickitemnodeinstance.cpp @@ -428,12 +428,14 @@ QImage QuickItemNodeInstance::renderImage() const nodeInstanceServer()->quickView()->afterRendering(); } + renderImage.setDevicePixelRatio(devicePixelRatio); #else renderImage = nodeInstanceServer()->quickView()->grabWindow(); + renderImage = renderImage.copy(renderBoundingRect.toRect()); + /* When grabbing an offscren window the device pixel ratio is 1 */ + renderImage.setDevicePixelRatio(1); #endif - renderImage.setDevicePixelRatio(devicePixelRatio); - return renderImage; } @@ -462,6 +464,7 @@ QImage QuickItemNodeInstance::renderPreviewImage(const QSize &previewImageSize) } #else image = nodeInstanceServer()->quickView()->grabWindow(); + image = image.copy(previewItemBoundingRect.toRect()); #endif image = image.scaledToWidth(size.width()); |