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 send value in QImage to image source QML
QtWS25 Last Chance

How send value in QImage to image source QML

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
qmlimage displaymysql
3 Posts 3 Posters 4.1k 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.
  • M Offline
    M Offline
    MrErfan
    wrote on 14 Nov 2016, 15:29 last edited by A Former User
    #1

    Hi, thank you gave that answer
    I want my picture taken from the database and set its value to QImage have send to Qml image(source:myimg), and displays it on.
    I do not want to save the image. But I want to get it directly from C ++, and I send it to Qml

            QVariant currentImage = eQuery.value(5).toByteArray();
            QByteArray bytes = currentImage.toByteArray();
            QImage image;
            image.loadFromData(bytes);
            qDebug() << (image.width());
    
    

    In the above code in a line of five width of the image, printed
    So this means that the above code works pretty well .
    And now my question is how much Qimage to return the Qml (image{source:...}). thanks

    P 1 Reply Last reply 15 Nov 2016, 04:49
    0
    • S Offline
      S Offline
      Schluchti
      wrote on 14 Nov 2016, 17:19 last edited by
      #2

      If I understand you correctly, a QQuickImageProvider might be what you are looking for. http://doc.qt.io/qt-5/qquickimageprovider.html

      Want to read more about Qt?

      https://gympulsr.com/blog/qt/

      Latest Article: https://gympulsr.com/blog/qt/2017/06/14/ios-background-music-qt.html

      1 Reply Last reply
      1
      • M MrErfan
        14 Nov 2016, 15:29

        Hi, thank you gave that answer
        I want my picture taken from the database and set its value to QImage have send to Qml image(source:myimg), and displays it on.
        I do not want to save the image. But I want to get it directly from C ++, and I send it to Qml

                QVariant currentImage = eQuery.value(5).toByteArray();
                QByteArray bytes = currentImage.toByteArray();
                QImage image;
                image.loadFromData(bytes);
                qDebug() << (image.width());
        
        

        In the above code in a line of five width of the image, printed
        So this means that the above code works pretty well .
        And now my question is how much Qimage to return the Qml (image{source:...}). thanks

        P Offline
        P Offline
        p3c0
        Moderators
        wrote on 15 Nov 2016, 04:49 last edited by
        #3

        @MrErfan Did you not check you earlier deleted post ? It had a few answers.

        @MrErfan To add to @neda's answer you can convert the image to base64 and set this as value to Image's source property.
        Something like:

        imageObj->setProperty("source", "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADwAAAA8CAYAAAA6/NlyAAAQvUlEQVRo3t2beYxd1X3Hv79zzr33LTNv3iwez+aNDOCw2WAMKSIgpTZJaUA0SkkrNWnTVhBFolG6pJIb2ihFFk3/aEBJF0VVk0pJS5eoCYVCYwjEwhTbY4PBi7A9tpkZ27O/W

        157

        1 Reply Last reply
        2

        1/3

        14 Nov 2016, 15:29

        • Login

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