From 7048a89fa1769abcd836a9b606b53cb88747cac8 Mon Sep 17 00:00:00 2001 From: Michael Winkelmann Date: Mon, 30 Nov 2020 16:29:02 +0100 Subject: [PATCH] FormEditor: Return correct bounding rect for rendered QPicture The bounding rect is calculated by union of all child item boundings rect of all FormEditorItems. Change-Id: I908e9d08b581671436bc7334b3b7eb0a5cd25aa8 Reviewed-by: Marco Bubke --- .../qmldesigner/components/formeditor/formeditorwidget.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/plugins/qmldesigner/components/formeditor/formeditorwidget.cpp b/src/plugins/qmldesigner/components/formeditor/formeditorwidget.cpp index e858ae56376..63c7e05d603 100644 --- a/src/plugins/qmldesigner/components/formeditor/formeditorwidget.cpp +++ b/src/plugins/qmldesigner/components/formeditor/formeditorwidget.cpp @@ -512,8 +512,13 @@ QPicture FormEditorWidget::renderToPicture() const QPainter painter{&picture}; const QTransform viewportTransform = m_graphicsView->viewportTransform(); - const QRectF boundingRect = rootItemRect(); + auto items = m_formEditorView->scene()->allFormEditorItems(); + QRectF boundingRect; + for (auto &item : items) + boundingRect |= item->childrenBoundingRect(); + + picture.setBoundingRect(boundingRect.toRect()); m_graphicsView->render(&painter, boundingRect, viewportTransform.mapRect(boundingRect.toRect())); return picture;