How to Capture an Image in a QML
-
I would like to save an image when my QML application is running, just like a camera inside the application,
How can i do that? -
The source code for the qmlviewer app uses the line
@
QPixmap::grabWidget(canvas).save(snapFileName);
@where canvas is the QDeclarativeView* and snapFileName is the filename to save.
-
where will be the destination of the saved image that i capture?
-
[quote author="jr_jags" date="1314181801"]where will be the destination of the saved image that i capture?[/quote]
To the application's working path so I'd add a path to the file. something like QDir::homePath() + "/fileName" -
can i use this in QML?
-
You'll need to write some C++ code to handle this. However, with a slot or a Q_INVOKABLE method, you can trigger the functionality from your QML code.
-
so ill use the .cpp file to use screenshot on my qml
-
yes, put the @mlong inside a slot. Optionally you can pass the path to which you want to save as a parameter.