Important: Please read the Qt Code of Conduct -

How to use qml to cut a part of one picture?

  • use qml how to implement cut a picture?

  • What are you mean by cut a picture with QML ? You want to just display a part of picture, or you want to save a part of picture into file. They're totally different.

  • oh sorry! maybe i don't express clearly,i want to save a part of picture into file,so can you give me any advice?

  • Hi sfjam, i'm sorry, but there is no direct way to do this. I'm not familiar with image editing, but i think maybe there are 2 ways to make it.

    The first approach is: Use QPixmap::grabWidget() to grab your picture which been cut inside the QWidget's paintEvent, and display it in your QML view or save the pixmap to file.

    Another one is: use lowlevel api's to manipulate the picture's data, cut, chop, rotate or do everything you like.

    But all of them are not done by QML(Even you can create a QML plugin)


  • Chuck Gao,i'm very appreciate for you reply!thanks very much!

  • As QML is mostly for UI work, I would suggest you expose a 'CropSave' function or similar from the underlying Qt (C++) that you can then call from QML.
    You'd probably want a whole set of backend C++ functions if you are making a QML image editor program.

Log in to reply