diff --git a/src/gui/painting/qplatformbackingstore.cpp b/src/gui/painting/qplatformbackingstore.cpp
index 83077f38ca43178a955b81bd7c768ef8ce5af209..62492980de3d9f2c4c8e5e96d426ded6ee37b130 100644
--- a/src/gui/painting/qplatformbackingstore.cpp
+++ b/src/gui/painting/qplatformbackingstore.cpp
@@ -83,7 +83,7 @@ public:
 
 struct QBackingstoreTextureInfo
 {
-    QWidget *widget; // may be null
+    void *source; // may be null
     GLuint textureId;
     QRect rect;
     QRect clipRect;
@@ -125,10 +125,10 @@ GLuint QPlatformTextureList::textureId(int index) const
     return d->textures.at(index).textureId;
 }
 
-QWidget *QPlatformTextureList::widget(int index)
+void *QPlatformTextureList::source(int index)
 {
     Q_D(const QPlatformTextureList);
-    return d->textures.at(index).widget;
+    return d->textures.at(index).source;
 }
 
 QPlatformTextureList::Flags QPlatformTextureList::flags(int index) const
@@ -164,12 +164,12 @@ bool QPlatformTextureList::isLocked() const
     return d->locked;
 }
 
-void QPlatformTextureList::appendTexture(QWidget *widget, GLuint textureId, const QRect &geometry,
+void QPlatformTextureList::appendTexture(void *source, GLuint textureId, const QRect &geometry,
                                          const QRect &clipRect, Flags flags)
 {
     Q_D(QPlatformTextureList);
     QBackingstoreTextureInfo bi;
-    bi.widget = widget;
+    bi.source = source;
     bi.textureId = textureId;
     bi.rect = geometry;
     bi.clipRect = clipRect;
diff --git a/src/gui/painting/qplatformbackingstore.h b/src/gui/painting/qplatformbackingstore.h
index 5fa7e6dac0c1f9b003a06f41a584642f4df0c80e..eac97e9cf69c03538836699e43ed1b4be1a82ce2 100644
--- a/src/gui/painting/qplatformbackingstore.h
+++ b/src/gui/painting/qplatformbackingstore.h
@@ -83,12 +83,12 @@ public:
     GLuint textureId(int index) const;
     QRect geometry(int index) const;
     QRect clipRect(int index) const;
-    QWidget *widget(int index);
+    void *source(int index);
     Flags flags(int index) const;
     void lock(bool on);
     bool isLocked() const;
 
-    void appendTexture(QWidget *widget, GLuint textureId, const QRect &geometry,
+    void appendTexture(void *source, GLuint textureId, const QRect &geometry,
                        const QRect &clipRect = QRect(), Flags flags = 0);
     void clear();
 
diff --git a/src/platformsupport/platformcompositor/qopenglcompositorbackingstore.cpp b/src/platformsupport/platformcompositor/qopenglcompositorbackingstore.cpp
index 4cf64e61da03500ca68d444d2dd6281c9e8f25a3..8ce1ed2d2b4dda3a1debe3b198a576124da010b1 100644
--- a/src/platformsupport/platformcompositor/qopenglcompositorbackingstore.cpp
+++ b/src/platformsupport/platformcompositor/qopenglcompositorbackingstore.cpp
@@ -175,7 +175,7 @@ void QOpenGLCompositorBackingStore::composeAndFlush(QWindow *window, const QRegi
 
     m_textures->clear();
     for (int i = 0; i < textures->count(); ++i)
-        m_textures->appendTexture(textures->widget(i), textures->textureId(i), textures->geometry(i),
+        m_textures->appendTexture(textures->source(i), textures->textureId(i), textures->geometry(i),
                                   textures->clipRect(i), textures->flags(i));
 
     updateTexture();
diff --git a/src/widgets/kernel/qwidgetbackingstore.cpp b/src/widgets/kernel/qwidgetbackingstore.cpp
index 57523179247c84d5a44bbd836552f5cb821e904f..d1070839fa036f02452ae349bb04fbc5ade98e12 100644
--- a/src/widgets/kernel/qwidgetbackingstore.cpp
+++ b/src/widgets/kernel/qwidgetbackingstore.cpp
@@ -1157,7 +1157,7 @@ void QWidgetBackingStore::doSync()
 #ifndef QT_NO_OPENGL
     if (widgetTextures && widgetTextures->count()) {
         for (int i = 0; i < widgetTextures->count(); ++i) {
-            QWidget *w = widgetTextures->widget(i);
+            QWidget *w = static_cast<QWidget *>(widgetTextures->source(i));
             if (dirtyRenderToTextureWidgets.contains(w)) {
                 const QRect rect = widgetTextures->geometry(i); // mapped to the tlw already
                 dirty += rect;