Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Save image from qml
Forum Updated to NodeBB v4.3 + New Features

Save image from qml

Scheduled Pinned Locked Moved QML and Qt Quick
21 Posts 3 Posters 13.7k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    stereomatching
    wrote on last edited by
    #21

    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

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved