aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/quickwidgets/qquickwidget.cpp26
-rw-r--r--src/quickwidgets/qquickwidget_p.h1
2 files changed, 26 insertions, 1 deletions
diff --git a/src/quickwidgets/qquickwidget.cpp b/src/quickwidgets/qquickwidget.cpp
index b472664068..8b7a42de57 100644
--- a/src/quickwidgets/qquickwidget.cpp
+++ b/src/quickwidgets/qquickwidget.cpp
@@ -623,6 +623,22 @@ void QQuickWidgetPrivate::updateSize()
}
}
+/*!
+ \internal
+
+ Update the position of the offscreen window, so it matches the position of the QQuickWidget.
+ */
+void QQuickWidgetPrivate::updatePosition()
+{
+ Q_Q(QQuickWidget);
+ if (offscreenWindow == 0)
+ return;
+
+ const QPoint &pos = q->mapToGlobal(QPoint(0, 0));
+ if (offscreenWindow->position() != pos)
+ offscreenWindow->setPosition(pos);
+}
+
QSize QQuickWidgetPrivate::rootObjectSize() const
{
QSize rootObjectSize(0,0);
@@ -747,7 +763,11 @@ void QQuickWidget::createFramebufferObject()
d->fbo = new QOpenGLFramebufferObject(fboSize, format);
}
- d->offscreenWindow->setGeometry(0, 0, width(), height());
+ // Even though this is just an offscreen window we should set the position on it, as it might be
+ // useful for an item to know the actual position of the scene.
+ // Note: The position will be update when we get a move event (see: updatePosition()).
+ const QPoint &globalPos = mapToGlobal(QPoint(0, 0));
+ d->offscreenWindow->setGeometry(globalPos.x(), globalPos.y(), width(), height());
d->offscreenWindow->setRenderTarget(d->fbo);
if (samples > 0)
@@ -1100,6 +1120,10 @@ bool QQuickWidget::event(QEvent *e)
}
break;
+ case QEvent::Move:
+ d->updatePosition();
+ break;
+
default:
break;
}
diff --git a/src/quickwidgets/qquickwidget_p.h b/src/quickwidgets/qquickwidget_p.h
index c16ce2fece..6a5601e479 100644
--- a/src/quickwidgets/qquickwidget_p.h
+++ b/src/quickwidgets/qquickwidget_p.h
@@ -73,6 +73,7 @@ public:
void itemGeometryChanged(QQuickItem *item, const QRectF &newGeometry, const QRectF &oldGeometry);
void initResize();
void updateSize();
+ void updatePosition();
void updateFrambufferObjectSize();
void setRootObject(QObject *);
void render(bool needsSync);