Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. grabToImage ready connection problems

grabToImage ready connection problems

Scheduled Pinned Locked Moved Unsolved General and Desktop
connectiongrabtoimageqquickitemgrabr
1 Posts 1 Posters 290 Views
  • 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.
  • B Offline
    B Offline
    Bodda
    wrote on last edited by Bodda
    #1

    Re: Connecting a slot to a QSharedPointer (QQuickItem::grabToImage)

    Hi,
    I am trying to grabToImage on a QQuickItem that is pointed out by qml. But the connection in the cpp-file never gets triggered? My guess is that it is quick and gets triggered before the connection is created? If so, how can the connection be set up before calling grabToImage? Or is it something else that is faulty in this code?

    The only thing printed out when this programis executed is:
    grabImage, m_sourceItem = QQuickItem(0x65ac80, parent=0x6ce490, geometry=0,0 100x80)

    cpp-file (only more relevant parts shown) for C++ component

    void QmlImageGrabber::grabImage(){
        //qDebug below prints out:  
        //grabImage, m_sourceItem = QQuickItem(0x65ac80, parent=0x6ce490, geometry=0,0 100x80)
        qDebug() << "grabImage, m_sourceItem =" << m_sourceItem; 
    
        m_imageGrabResult = m_sourceItem->grabToImage().data();
        connect(m_imageGrabResult, &QQuickItemGrabResult::ready, this, &QmlImageGrabber::grabImageReady);
    }
    
    void QmlImageGrabber::grabImageReady(){
        qDebug() << "This is never printed out!";
    
        //connection purpose fullfilled, disconnect
        disconnect(m_imageGrabResult, &QQuickItemGrabResult::ready, this, &QmlImageGrabber::grabImageReady);
    
        //Here I will do something more
    
        emit sourceChanged();
    }
    

    h-file for C++ component

    class QmlImageGrabber : public QObject
    {
        Q_OBJECT
    
        Q_PROPERTY(QQuickItem *source READ source WRITE setSource NOTIFY sourceChanged);
    
    public:
        QmlImageGrabber();
        ~QmlImageGrabber();
    
        QQuickItem* source();
        void setSource(QQuickItem *source);
    
    signals:
        void sourceChanged();
    
    private:
        void grabImage();
        void grabImageReady();
    
        QQuickItem *m_sourceItem = nullptr;
        QQuickItemGrabResult *m_imageGrabResult = nullptr;
    };
    
    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