aboutsummaryrefslogtreecommitdiffstats
path: root/src/quickwidgets
diff options
context:
space:
mode:
authorPaul Olav Tvete <paul.tvete@digia.com>2014-04-23 09:58:32 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-04-24 15:36:51 +0200
commita1eb1348ff8026a6c623981d06142769dc18ec78 (patch)
tree52f2c1924600a65c5fb828b00d7a3e2641ba0102 /src/quickwidgets
parent4f3a02c7cde6589ecbdbc4f0dcf20793d2d604db (diff)
Getting the render window of an offscreen window
When using a QQuickWidget, the QQuickWindow is hidden and the contents are displayed in another window. Some components need to query the actual window, e.g. when positioning a popup. Task-number: QTBUG-38116 Change-Id: I34452be2179ccc9e216e4d89264dc700e0cf42a0 Reviewed-by: Gunnar Sletta <gunnar.sletta@jollamobile.com>
Diffstat (limited to 'src/quickwidgets')
-rw-r--r--src/quickwidgets/qquickwidget.cpp24
1 files changed, 19 insertions, 5 deletions
diff --git a/src/quickwidgets/qquickwidget.cpp b/src/quickwidgets/qquickwidget.cpp
index e71da7e7ec..b6d72ac21d 100644
--- a/src/quickwidgets/qquickwidget.cpp
+++ b/src/quickwidgets/qquickwidget.cpp
@@ -66,10 +66,29 @@ QT_BEGIN_NAMESPACE
extern Q_GUI_EXPORT QImage qt_gl_read_framebuffer(const QSize &size, bool alpha_format, bool include_alpha);
+class QQuickWidgetRenderControl : public QQuickRenderControl
+{
+public:
+ QQuickWidgetRenderControl(QQuickWidget *quickwidget) : m_quickWidget(quickwidget) {}
+ QWindow *renderWindow(QPoint *offset) {
+ if (offset)
+ *offset = m_quickWidget->mapTo(m_quickWidget->window(), QPoint());
+ return m_quickWidget->window()->windowHandle();
+ }
+private:
+ QQuickWidget *m_quickWidget;
+};
+
void QQuickWidgetPrivate::init(QQmlEngine* e)
{
Q_Q(QQuickWidget);
+ renderControl = new QQuickWidgetRenderControl(q);
+ offscreenWindow = new QQuickWindow(renderControl);
+ offscreenWindow->setTitle(QString::fromLatin1("Offscreen"));
+ // Do not call create() on offscreenWindow.
+ createOffscreenSurface();
+
setRenderToTexture();
engine = e;
@@ -108,11 +127,6 @@ QQuickWidgetPrivate::QQuickWidgetPrivate()
, updatePending(false)
, fakeHidden(false)
{
- renderControl = new QQuickRenderControl;
- offscreenWindow = new QQuickWindow(renderControl);
- offscreenWindow->setTitle(QString::fromLatin1("Offscreen"));
- // Do not call create() on offscreenWindow.
- createOffscreenSurface();
}
QQuickWidgetPrivate::~QQuickWidgetPrivate()