0

I have found a class GrabWindow but I am a noobie in Qt Quick 2 and can't get how to use it.
Can a someone explain how can I use this view?
At this moment I added in my main function:

#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <QtQml>
#include "grabwindow.h"

int main(int argc, char *argv[]) {
    QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);

    QGuiApplication app(argc, argv);

    qmlRegisterType<GrabWindow>("test", 1, 0, "GrabWindow");

    QQmlApplicationEngine engine;

    engine.load(QUrl(QStringLiteral("qrc:/qml/SystemTray.qml")));
    if (engine.rootObjects().isEmpty()) {
        return -1;
    }

    GrabWindow grabWnd;
    grabWnd.setResizeMode(QQuickView::SizeViewToRootObject);
    grabWnd.setSource(QUrl(QStringLiteral("qrc:/qml/main.qml")));
    grabWnd.setFlags(Qt::Popup);
    grabWnd.show();

    return app.exec();
}

And my main.qml:

import QtQuick 2.9
import QtQuick.Controls 2.2

ApplicationWindow {
    id: window
    visible: true
    width: 320
    height: 480
    title: qsTr("test")
}

But on start I get that only:
Screenshot

How to get a screenshot using that class and remove a square at the left top corner of the screen?

ADDED
I use Ubuntu 17.10

Denis Sologub
  • 7,277
  • 11
  • 56
  • 123

0 Answers0