Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Call for Presentations - Qt World Summit

    QDataStream only accept Qt data types?

    General and Desktop
    2
    2
    365
    Loading More Posts
    • 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
      opengpu2 last edited by

      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 Reply Quote 1
      • A
        Andreas last edited by

        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 Reply Quote 0
        • First post
          Last post