Create images with QML
-
wrote on 27 Apr 2011, 07:39 last edited by
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
-
wrote on 27 Apr 2011, 08:03 last edited by
You can do it in C++.
@QGraphicsView::render@ -
wrote on 27 Apr 2011, 11:09 last edited by
You can use qmlviewer to save rendering to png.
-
wrote on 27 Apr 2011, 11:15 last edited by
This may be helpful:
"How to save an image from QML Image element?":http://developer.qt.nokia.com/forums/viewthread/3948 -
wrote on 27 Apr 2011, 14:35 last edited by
[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.
-
wrote on 27 Apr 2011, 14:58 last edited by
[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.
-
wrote on 28 Apr 2011, 11:12 last edited by
Precision : The snapshot file is created in the directory where you start qmlviewer.
Thanks all.
-
wrote on 28 Apr 2011, 11:36 last edited by
Of course, any screenshot-taking app would have sufficed for this.
-
wrote on 28 Apr 2011, 13:31 last edited by
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
-
wrote on 28 Apr 2011, 18:03 last edited by
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?
7/10