Expected behaviour: item.grabToImage() works as expected. Actual behaviour: "QML <ItemType>: grabToImage: item's window is not visible" Example: --- import QtQuick 2.6 import org.kde.kcm 1.2 as KCM KCM.ScrollViewKCM { Rectangle { id: rect width: 50 height: 50 color: "red" MouseArea { anchors.fill: parent onClicked: { rect.grabToImage(function(result) {}) // QML Rectangle: grabToImage: item's window is not visible } } } } ---
Looks like a Qt bug. We use QQuickWidget to embed QtQuick into a widget window which uses an offscreen window. if (!item->window()->isVisible()) { qmlWarning(item) << "grabToImage: item's window is not visible"; return nullptr; } I wonder if using QQuickRenderControl::renderWindowFor(item->window()) instad of item->window() directly here would work
https://codereview.qt-project.org/c/qt/qtdeclarative/+/298069