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?
QtWS25 Last Chance

QDataStream only accept Qt data types?

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 477 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 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 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

      • Login

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