Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

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

    QML and Qt Quick
    3
    6
    3876
    Loading More Posts
    • 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
      sfjam last edited by

      use qml how to implement cut a picture?

      1 Reply Last reply Reply Quote 0
      • C
        Chuck Gao last edited by

        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.

        Chuck

        1 Reply Last reply Reply Quote 0
        • S
          sfjam last edited by

          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?

          1 Reply Last reply Reply Quote 0
          • C
            Chuck Gao last edited by

            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)

            Br,

            Chuck

            1 Reply Last reply Reply Quote 0
            • S
              sfjam last edited by

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

              1 Reply Last reply Reply Quote 0
              • X
                xsacha last edited by

                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.

                • Sacha
                1 Reply Last reply Reply Quote 0
                • First post
                  Last post