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. Multi images in QML using one QQuickImageProvider ?

Multi images in QML using one QQuickImageProvider ?

Scheduled Pinned Locked Moved Solved QML and Qt Quick
3 Posts 2 Posters 680 Views
  • 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.
  • V Offline
    V Offline
    VincentLiu
    wrote on last edited by
    #1

    Hi,

    Does anyone know if it is possible to display multi images from C++ in QML using QQuickImageProvider?

    i. e., I have two image elements in QML, and I want to show different images from C++ inside ths image elements. I don't want and even don't know if it is good to create separate QQuickImageProviders for each image. Consequently, I want to use the same QQuickImageProvider to pass the images to QML. Really need your help. Thanks.

    1 Reply Last reply
    0
    • p3c0P Offline
      p3c0P Offline
      p3c0
      Moderators
      wrote on last edited by
      #2

      @VincentLiu If I understand correctly, it is possible. Just use different id.
      Here is its example:
      http://doc.qt.io/qt-5/qquickimageprovider.html#an-example

      157

      1 Reply Last reply
      1
      • V Offline
        V Offline
        VincentLiu
        wrote on last edited by p3c0
        #3

        Dear @p3c0 ,

        Very thanks for your help. You are right. Here is my code for sharing to others having the same problem.

        In .QML:

        property int num1;
        property int num2;
        
        Image{
            source: "image://*provider*/" + num1
        }
        
        Image{
            source: "image://*provider*/" + num2
        }
        
        Button{
            onClicked: 
            {
                num1++;
            }
        }
        
        Button{
            onClicked:
            {
                num2++;
            }
        }
        
        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