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. Use Image in qml from C++
Qt 6.11 is out! See what's new in the release blog

Use Image in qml from C++

Scheduled Pinned Locked Moved Solved QML and Qt Quick
4 Posts 2 Posters 506 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.
  • B Offline
    B Offline
    BlinCt
    wrote on last edited by
    #1

    I want to display an image in qml, I also need rotation, zoom, and stretching in height and width(fitToWidth and fitToHeight).

    The C++ picture class has rotation and stretching methods, which is very important to me, but I didn’t find an object in qml Image, and so I’m trying to understand whether I can open an image in the C++ class, use its functions and then put it in qml display?
    If I'm wrong and there is another way, I would be grateful if someone could explain it to me.
    Thank you.

    sierdzioS 1 Reply Last reply
    0
    • B BlinCt

      I want to display an image in qml, I also need rotation, zoom, and stretching in height and width(fitToWidth and fitToHeight).

      The C++ picture class has rotation and stretching methods, which is very important to me, but I didn’t find an object in qml Image, and so I’m trying to understand whether I can open an image in the C++ class, use its functions and then put it in qml display?
      If I'm wrong and there is another way, I would be grateful if someone could explain it to me.
      Thank you.

      sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      @BlinCt I think QQuickImageProvider is your friend here if you want to use QImage API.

      However, from transformations you mention all are available in QML, but under different names:

      • rotation
      • zoom: see scale
      • stretching: see fillMode

      (Z(:^

      B 1 Reply Last reply
      2
      • B BlinCt has marked this topic as solved on
      • sierdzioS sierdzio

        @BlinCt I think QQuickImageProvider is your friend here if you want to use QImage API.

        However, from transformations you mention all are available in QML, but under different names:

        • rotation
        • zoom: see scale
        • stretching: see fillMode
        B Offline
        B Offline
        BlinCt
        wrote on last edited by
        #3

        @sierdzio My question is, if I use QQuickImageProvider to work with an image, that is, with its help I will open the Image when I need to rotate it, zoom it. How can I transfer it to qml in order to work with it? In qml this object will not be an Image?
        Thx for answer

        sierdzioS 1 Reply Last reply
        0
        • B BlinCt

          @sierdzio My question is, if I use QQuickImageProvider to work with an image, that is, with its help I will open the Image when I need to rotate it, zoom it. How can I transfer it to qml in order to work with it? In qml this object will not be an Image?
          Thx for answer

          sierdzioS Offline
          sierdzioS Offline
          sierdzio
          Moderators
          wrote on last edited by
          #4

          @BlinCt Please read the docs and it should become clear. On QML side, you still have an Image component, you simply use a specific path which points to your image provider instance.

          Btw. yet another option for you, especially useful if you need to do some more advanced stuff: you can subclass QQuickPaintedItem and do the painting and image manipulations using QPainter.

          (Z(:^

          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