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. [Solved]help serializing a QMultiHash
Forum Updated to NodeBB v4.3 + New Features

[Solved]help serializing a QMultiHash

Scheduled Pinned Locked Moved General and Desktop
7 Posts 4 Posters 3.1k 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.
  • S Offline
    S Offline
    sinjar
    wrote on last edited by
    #1

    i get this error:
    @
    /usr/QtSDK/Desktop/Qt/473/gcc/include/QtCore/qdatastream.h:362: error: no match for ‘operator>>’ in ‘operator>>((* & in), (* & k)) >> t’
    @

    I am trying to serialize a QMultiHash<QString,IndexItem> using QDataStream.. i have already defined operator << and >> for IndexItem like this:
    @
    QDataStream & operator<<(QDataStream & stream,const IndexItem & item);
    QDataStream & operator>>(QDataStream & in,IndexItem & item);
    @

    wherein i have serialized the contents of IndexItem...

    I get the error when i do
    @
    stream >> index
    @
    and
    @
    stream << index
    @
    where stream is a QDataStream and index is the QMultiHash

    I get a similar error
    @
    /usr/QtSDK/Desktop/Qt/473/gcc/include/QtCore/qdatastream.h:381: error: no match for ‘operator<<’ in ‘operator<<((* & out), (* & it.QHash<Key, T>::const_iterator::key with Key = QString, T = IndexItem)) << it.QHash<Key, T>::const_iterator::value with Key = QString, T = IndexItem’
    @
    PLEASE HELP

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

      Do you get the same error if you try to stream an IndexItem directly?

      1 Reply Last reply
      0
      • V Offline
        V Offline
        veeeee_d
        wrote on last edited by
        #3

        Can you also specify the declaration of your QMultiHash?

        1 Reply Last reply
        0
        • G Offline
          G Offline
          goetz
          wrote on last edited by
          #4

          Where did you define the operators? They should not be part of the IndexItem class, but be declared in the header of your IndexItem class. Also, make sure the the operators' header file is included if you declare them elswhere.

          http://www.catb.org/~esr/faqs/smart-questions.html

          1 Reply Last reply
          0
          • S Offline
            S Offline
            sinjar
            wrote on last edited by
            #5

            Volker: They are declared in the header outside the class.

            veeeee_d:
            It is declared inside a class called Engine as a private member
            @
            QMultiHash<QString,IndexItem> index;
            @

            Andre:
            Haven't tried that... Will try that and tell you...

            1 Reply Last reply
            0
            • S Offline
              S Offline
              sinjar
              wrote on last edited by
              #6

              Thanks all.. i wasnt including the correct header.. I had a copy (for backup) which did not contain the stream operators.. and my program was including that one instead of the one I was editing... ;)

              1 Reply Last reply
              0
              • A Offline
                A Offline
                andre
                wrote on last edited by
                #7

                Doh!
                I guess we have all been in similar situations. I certainly have!

                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