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. How to use qml to cut a part of one picture?
Qt 6.11 is out! See what's new in the release blog

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

Scheduled Pinned Locked Moved QML and Qt Quick
6 Posts 3 Posters 5.0k 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
    sfjam
    wrote on last edited by
    #1

    use qml how to implement cut a picture?

    1 Reply Last reply
    0
    • C Offline
      C Offline
      Chuck Gao
      wrote on last edited by
      #2

      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
      0
      • S Offline
        S Offline
        sfjam
        wrote on last edited by
        #3

        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
        0
        • C Offline
          C Offline
          Chuck Gao
          wrote on last edited by
          #4

          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
          0
          • S Offline
            S Offline
            sfjam
            wrote on last edited by
            #5

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

            1 Reply Last reply
            0
            • X Offline
              X Offline
              xsacha
              wrote on last edited by
              #6

              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
              0

              • Login

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