Grab() function of QQuickView would crash on android
-
mac OS X 10.8.5
Qt5.2tried api 10,14,15,19
compile with armeabierror message
F/libc (30728): Fatal signal 11 (SIGSEGV) at 0x00000004 (code=1), thread 30752 (ple.androidTest).hpp
@
#ifndef SCREENCAPTURE_HPP
#define SCREENCAPTURE_HPP#include <QObject>
class QQuickView;
class screenCapture : public QObject
{
Q_OBJECT
public:
explicit screenCapture(QQuickView *parent = 0);
screenCapture& operator=(screenCapture const&) = delete;
screenCapture(screenCapture const&) = delete;Q_INVOKABLE void capture();
private:
//QtQuick2ApplicationViewer *currentView_;
QQuickView *currentView_;QString previous_name_;
};
#endif // SCREENCAPTURE_HPP
@.cpp
@
#include <QQuickView>#include "screenCapture.hpp"
screenCapture::screenCapture(QQuickView *parent) :
QObject(nullptr), currentView_(parent)
{
}/**
- @brief capture screen
*/
void screenCapture::capture()
{
currentView_->grabWindow();
}
@
main.cpp
@
#include <QtGui/QGuiApplication>
#include "qtquick2applicationviewer.h"#include <QQuickPaintedItem>
#include "screenCapture.hpp"
int main(int argc, char *argv[])
{
QGuiApplication app(argc, argv);qmlRegisterType<screenCapture>("ScreenCapture", 1, 0, "ScreenCap"); QtQuick2ApplicationViewer viewer; viewer.setMainQmlFile(QStringLiteral("qml/androidTest/main.qml")); viewer.showExpanded(); return app.exec();
}
@
main.qml
@
import QtQuick 2.0import ScreenCapture 1.0
Rectangle {
width: 360
height: 360ScreenCap{id: cap} MouseArea { id: mouseArea anchors.fill: parent onClicked: { cap.capture() } }
}
@
- @brief capture screen