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. QDataStream only accept Qt data types?
Forum Update on Monday, May 27th 2025

QDataStream only accept Qt data types?

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 484 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.
  • O Offline
    O Offline
    opengpu2
    wrote on 19 Mar 2015, 13:02 last edited by
    #1

    when i use Drag & Drop
    QByteArray itemData = event->mimeData()->data("xxx");
    QDataStream dataStream(&itemData, QIODevice::WriteOnly);
    QString xxx;
    dataStream << xxx;

    can i pass other data type such as std::sting to dataStream, or even my own string type?

    thank you

    1 Reply Last reply
    1
    • A Offline
      A Offline
      Andreas
      wrote on 19 Mar 2015, 13:22 last edited by
      #2

      Hello,

      You have to write your own implemenation of QDataStream operators (<<,>>) for your String Class e.g. MyString

      QDataStream &operator<<(QDataStream &out, const MyString &string)
      {......}

      QDataStream &operator>>(QDataStream &in, MyString &string)
      {......}

      --
      Andreas

      1 Reply Last reply
      0

      2/2

      19 Mar 2015, 13:22

      • Login

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