17 #include "windowscreenshotprovider.h"
19 #include <QGuiApplication>
20 #include <QQuickWindow>
22 WindowScreenshotProvider::WindowScreenshotProvider()
23 : QQuickImageProvider(QQmlImageProviderBase::Image, 0)
34 QImage WindowScreenshotProvider::requestImage(
const QString &
id, QSize *size,
const QSize &requestedSize)
37 Q_UNUSED(requestedSize);
39 QWindowList windows = QGuiApplication::topLevelWindows();
41 if (windows.count() != 1) {
47 QQuickWindow *quickWindow = qobject_cast<QQuickWindow *>(windows[0]);
55 QImage image = quickWindow->grabWindow();
56 size->rwidth() = image.width();
57 size->rheight() = image.height();