Create images with QML



  • Hello,

    I have a simple pixmap to design and was wondering if I could do it in QtCreator with the QML editor, I only need rectangle with some text and colors.

    But I have to save it to image file, let's say png. Is it possible to somewhat export the qml rendering and save as image ?

    Thanks



  • You can do it in C++.
    @QGraphicsView::render@



  • You can use qmlviewer to save rendering to png.



  • This may be helpful:
    "How to save an image from QML Image element?":http://developer.qt.nokia.com/forums/viewthread/3948



  • [quote author="minimoog77" date="1303902570"]You can use qmlviewer to save rendering to png.[/quote]

    Would be what I search for but can't find how to do this with qmlviewer... The only option I see is "recording" -> "take a snapshot (F3)" but even with this I can't get nor save the image of the snapshot.



  • [quote author="ness522" date="1303914947"]
    Would be what I search for but can't find how to do this with qmlviewer... The only option I see is "recording" -> "take a snapshot (F3)" but even with this I can't get nor save the image of the snapshot.
    [/quote]

    The snapshot will be saved as "snapshot1.png" in the same folder with your qml-file.



  • Precision : The snapshot file is created in the directory where you start qmlviewer.

    Thanks all.



  • Of course, any screenshot-taking app would have sufficed for this.



  • Of course, things are not always so simple, I have some transparent areas that needs to remain transparent in the image export.

    But this transparency doesn't work with the snapshot feature of qmlviewer...

    I'm trying to use qml in place of gimp or photoshot for a simple design


  • Moderators

    That does add another layer of difficulty. Probably should have mentioned that requirement earlier on. Could you mask out the transparent area with a neutral color, perhaps, and remove it later on using GIMP or Photoshop? Or are you looking for partial transparency?


Log in to reply
 

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