Grab() function of QQuickView would crash on android



  • mac OS X 10.8.5
    Qt5.2

    tried api 10,14,15,19
    compile with armeabi

    error 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&#40;QStringLiteral("qml/androidTest/main.qml"&#41;&#41;;
    viewer.showExpanded();
    
    return app.exec&#40;&#41;;
    

    }

    @

    main.qml
    @
    import QtQuick 2.0

    import ScreenCapture 1.0

    Rectangle {
    width: 360
    height: 360

    ScreenCap{id: cap}
    
    MouseArea {
        id: mouseArea
    
        anchors.fill: parent
    
        onClicked: {
            cap.capture()
        }
    }    
    

    }

    @


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.