[Solved]Render a QML scene into a texture and save it



  • How could I translate the QML scene(like Rectangle, Image etc) into a texture and save it?
    Anyone tried this before?If I can translate the components to texture, then I should be able to save
    the image after processing by particle systems or shaderEffects



  • Looks like shaderEffectSource could render the qml scene to texture, but it do not provide a way for us to access the texture or save it, do anyone know where are the plug in source codes of the shaderEffectSource?



  • Example:

    @
    Rectangle{
    id:root

    widht:640
    height: 480

    ToTexture{ id: toTexture} //a new type created by c++

    MouseArea{

     anchors.fill: parent
    
     onClicked: {         
         toTexture.saveAsTexture(root)
     }
    

    }
    }
    @

    The problem is, how could I design a new type like "ToTexture"? The example of " Scene Graph - OpenGL Under QML." show us how to render a qml scene, but I can't find an example show us how to transfer the qml scene to a texture.

    Without this function, I can't save the graph generated QtQuick



  • I found the other example

    "take screenshot":http://qt-project.org/forums/viewthread/28822/

    Take the screenshot by QQuickView, then do what we want


Log in to reply
 

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