Printscreen QML Item



  • Hi,
    is there a way to get snapshot of QML item or component, i.e. to get a picture of the item exactly how it is rendered on the user's screen?

    I can think of taking screenshot of the application window and then crop the area to get the item or component, but is there a better way?



  • Hi,

    From your QML code, you can use the grabToImage method of Item, e.g. myQmlItem.grabToImage(function(result) { result.saveToFile("myImage.png"); });

    You can also use a custom image size, e.g. myQmlItem.grabToImage(function(result) { result.saveToFile("myImage.png"); }, Qt.size(1000, 1000));


Log in to reply
 

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