Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to transmit a picture via socket?
Qt 6.11 is out! See what's new in the release blog

How to transmit a picture via socket?

Scheduled Pinned Locked Moved General and Desktop
3 Posts 3 Posters 1.5k 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.
  • H Offline
    H Offline
    hyzhappy
    wrote on last edited by
    #1

    I want to transmit data which text and picture are mixed, then display them in a QTextBrowser. What to do? Should I change a QImage into a QByteArray. But how to detach text and picture. Is there any solution?
    Thx.

    <append>
    What I want is socket read/write these different types data as binary stream. For example, I write a stream "hello world" as a text and append "0x01,0x02..."
    as a picture binary stream. How can client recognize which part is text, which part is picture binary stream.
    I think maybe I can use XML to mark it. Is there another good way?
    </append>

    1 Reply Last reply
    0
    • M Offline
      M Offline
      msue
      wrote on last edited by
      #2

      You write them (qimage and qstring) into the byte array (one after the other) using the << operator. On "the other side" you get them back (in the same order in which you wrote them in) using the >> operator.
      Just so. The operators will do the work for you. Nothing to worry about.

      1 Reply Last reply
      0
      • dheerendraD Offline
        dheerendraD Offline
        dheerendra
        Moderators Qt Champions 2024 Qt Champions 2022 Qt Champions 2017
        wrote on last edited by
        #3

        You can refer this post as well http://qt-project.org/forums/viewthread/44940/

        Dheerendra
        @Community Service
        Certified Qt Specialist
        https://www.pthinks.com

        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