Save image from qml
-
I tried Canvas, can't work either
If you just need to load and save the image
here is a simple class for that.hpp
@
#include <QImage>
#include <QObject>class QQuickItem;
class QString;class imageSaver : public QObject
{
Q_OBJECT
public:
explicit imageSaver(QObject *parent = 0);
imageSaver(imageSaver const&) = delete;
imageSaver& operator=(imageSaver const&) = delete;public slots:
void load(QString const &path);
void loadAndSave(QString const &path);
void save(QString const &path) const;private:
QImage img_;
};
@.cpp
@
#include "imageSaver.hpp"imageSaver::imageSaver(QObject *parent) :
QObject(parent)
{}
void imageSaver::load(QString const &path)
{
img_.load(path);
}void imageSaver::loadAndSave(QString const &path)
{
img_.load(path);
img_.save(path);
}void imageSaver::save(const QString &path) const
{
img_.save(path);
}
@if you need to take the result after postprocessing, take the screenshot
"take screenshot":http://qt-project.org/forums/viewthread/28822/With these, we can keep on using the Image from qml2
no error handle, please refine it by yourself