Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

grabtoimage() and scale produces two overlapping images?



  • Hi, if I use grabtoimage() in C++ for a scaled QQuickItem I get two overapping images. One with scale=1 the other one with the scale used in Qml.

    Item {
        id: iItem
        objectname: "oItem"
        width: 200
        height: 200
        scale: 0.5
    }
    
    QQuickItem *visPlc= m_pRootObj->findChild<QQuickItem*>("oItem");
    
    QEventLoop loop;
    QSharedPointer<QQuickItemGrabResult> grabRes = visPlc->grabToImage();
    loop.connect(grabRes.data(), &QQuickItemGrabResult::ready, &loop, &QEventLoop::quit);
    loop.exec();
    loop.exit();
    

    Is there a way only to get the scaled item?



  • For who is interested, I changed the following:

    Wrong double images:

    Item {
        id: iItem1
        objectname: "oItem"
        width: iItem2.width
        height: iItem2.height
        scale: 0.5 // moved to iItem2
    
       Item {
           id: iItem2
           width: 200
           height: 200
       }
    }
    

    Single image:

    Item {
        id: iItem1
        objectname: "oItem"
        width: iItem2.width
        height: iItem2.height
    
       Item {
           id: iItem2
           width: 200
           height: 200
           scale: 0.5
       }
    }
    

Log in to reply