Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Grab() function of QQuickView would crash on android
Forum Updated to NodeBB v4.3 + New Features

Grab() function of QQuickView would crash on android

Scheduled Pinned Locked Moved Mobile and Embedded
1 Posts 1 Posters 890 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    stereomatching
    wrote on last edited by
    #1

    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()
        }
    }    
    

    }

    @

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved