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
Forum Updated to NodeBB v4.3 + New Features

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 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.
  • MrErfanM Offline
    MrErfanM Offline
    MrErfan
    wrote on 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

    p3c0P 1 Reply Last reply
    0
    • S Offline
      S Offline
      Schluchti
      wrote on 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
      • MrErfanM MrErfan

        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

        p3c0P Offline
        p3c0P Offline
        p3c0
        Moderators
        wrote on 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

        • Login

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