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. Handle ArrayBuffer received via WebSocket's binaryMessageReceived() with QML
QtWS25 Last Chance

Handle ArrayBuffer received via WebSocket's binaryMessageReceived() with QML

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
qmlwebsocketbinaryimage
3 Posts 2 Posters 2.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.
  • D Offline
    D Offline
    danyright
    wrote on last edited by
    #1

    Hi everyone,

    I can't find any information getting even close to what I'm looking for - hope someone can be of help.

    I'm trying to receive an image sent from C++ as ByteArray via WebSockets in a QML app.

    Since there is a newly added (in Qt 5.8) Signal for the WebSocket QML Type that should do just that, I figured I'd use it (see http://doc-snapshots.qt.io/qt5-dev/qml-qtwebsockets-websocket.html#binaryMessageReceived-signal - beware the documentation error, the binaryMessageReceived Signal has an ArrayBuffer as parameter and not a QString, as reported: https://bugreports.qt.io/browse/QTBUG-57906).

    However, I have no idea how to handle the ArrayBuffer / binary message that is received in order to show it in a QML object (Image ? Canvas ?).

    Can anyone explain to me how this can be done ?

    Thanks for your help !
    Daniel

    1 Reply Last reply
    0
    • A Offline
      A Offline
      ambershark
      wrote on last edited by
      #2

      This code looks like it would do the trick. Once you have a url object you should be able to use that as the source for an Image.

      https://gist.github.com/candycode/f18ae1767b2b0aba568e

      This is an assumption on my part but it's something you could look into. :)

      My L-GPL'd C++ Logger github.com/ambershark-mike/sharklog

      1 Reply Last reply
      1
      • D Offline
        D Offline
        danyright
        wrote on last edited by
        #3

        Thanks for the link !

        I haven't yet been able to get it working.
        But I suspect I should probably be using a Loader with a Canvas component, instead of a simple Image element.

        I'll test it out and let you know.
        If anyone has a working code, don't hesitate to share ^^
        I'm sure it would be a great example to include in the docs.

        Daniel

        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