From 98c735be6e3335fd19a7fbd2a23b7938d69ecfe5 Mon Sep 17 00:00:00 2001 From: Thomas Hartmann Date: Tue, 10 Nov 2020 16:45:59 +0100 Subject: 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 --- .../qml/qmlpuppet/qml2puppet/instances/quickitemnodeinstance.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'share/qtcreator/qml/qmlpuppet/qml2puppet/instances/quickitemnodeinstance.cpp') 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()); -- cgit v1.2.3