Results 1 to 3 of 3

Thread: Render a QML scene into a texture and save it

  1. #1
    Join Date
    Jan 2011
    Posts
    127
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    42
    Thanked 4 Times in 4 Posts

    Default 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

  2. #2
    Join Date
    Jan 2011
    Posts
    127
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    42
    Thanked 4 Times in 4 Posts

    Default Re: Render a QML scene into a texture and save it

    Example:
    Qt Code:
    1. Rectangle{
    2. id:root
    3.  
    4. widht:640
    5. height: 480
    6.  
    7. ToTexture{ id: toTexture} //a new type created by c++
    8.  
    9. MouseArea{
    10.  
    11. anchors.fill: parent
    12.  
    13. onClicked: {
    14. toTexture.saveAsTexture(root) //this function will transfer the root item to texture and save it into QImage
    15. }
    16. }
    17. }
    To copy to clipboard, switch view to plain text mode 

    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.

  3. #3
    Join Date
    Jan 2011
    Posts
    127
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    42
    Thanked 4 Times in 4 Posts

    Default Re: Render a QML scene into a texture and save it

    I found a way to do it

    http://www.qtcentre.org/threads/5496...eenShot-Qt-QML

    We could take the screenshot, then render the QImage to texture

Similar Threads

  1. Replies: 4
    Last Post: 30th May 2012, 00:37
  2. Qt4 QGLwidget::renderPixmap don't render texture
    By Glandelf in forum Qt Programming
    Replies: 1
    Last Post: 5th May 2012, 21:20
  3. QGLWidget render or QGraphicsView with GL viewport render
    By QTInfinity in forum Qt Programming
    Replies: 2
    Last Post: 28th November 2011, 12:34
  4. OpenGL render to texture
    By Nicuvëo in forum Qt Programming
    Replies: 2
    Last Post: 26th March 2011, 13:07
  5. Creating a scene from piece of another scene
    By maverick_pol in forum Qt Programming
    Replies: 3
    Last Post: 23rd August 2007, 18:51

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.