Results 1 to 3 of 3

Thread: QDataSteam.

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jun 2010
    Posts
    38
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    3

    Default QDataSteam.

    I want write a class which is inherit from QObject to the file with QDataStream, so I overload operator << and operator >>.
    Qt Code:
    1. Class C : public QObject
    2. {
    3. Q_OBJECT
    4. ......
    5. friend QDataStream & operator << (QDataStream &dataStream, C &c);
    6. friend QDataStream & operator >> (QDataStream &dataStream, C &C);
    7. .......
    8. }
    9.  
    10. .................
    11. QDataStream & operator << (QDataStream &dataStream, C &c)
    12. {
    13.  
    14. }
    15.  
    16. QDataStream & operator >> (QDataStream &dataStream, C &c)
    17. {
    18.  
    19. }
    To copy to clipboard, switch view to plain text mode 

    but it can't compile success.The error is:multiple definition of "operator" <<(QDataStream&,C&)
    multiple definition of "operator" >>(QDataStream&,C&)

    if this class is not inherit from the QObject and delete macro Q_OBJECT, then it will compile success. So What's the problem....?
    Last edited by wysota; 13th September 2010 at 15:25.

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.