Results 1 to 8 of 8

Thread: no match for 'operator>>' (operand types are 'QDataStream' and 'double')

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2016
    Location
    Finland
    Posts
    5
    Thanks
    1
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows Android

    Default Re: no match for 'operator>>' (operand types are 'QDataStream' and 'double')

    Yeap, I've come to collect the stupid Feel free to pass it on
    I have a similar problem here except the problem persists even after the argument was changed to a non-const. Any idea as to why that might happen? Below is the implementation of the two operators.

    Qt Code:
    1. QDataStream &operator <<(QDataStream &out, const PID &pid)
    2. {
    3. out << pid.getKp() << pid.getKi() << pid.getKd();
    4. return out;
    5. }
    6.  
    7.  
    8. QDataStream &operator >>(QDataStream &in, PID &pid)
    9. {
    10. in >> pid.getKp() >> pid.getKi() >> pid.getKd();
    11. return in;
    12. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: no match for 'operator>>' (operand types are 'QDataStream' and 'double')

    Do the getter functions, e.g. PID.getKp(), return a reference to which the >> operator could write?

    Cheers,
    _

  3. #3
    Join Date
    Jan 2016
    Location
    Finland
    Posts
    5
    Thanks
    1
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows Android

    Default Re: no match for 'operator>>' (operand types are 'QDataStream' and 'double')

    Yes that was the problem. Thank you. I changed it to the code below and now it's okay. I guess I'll wear my cap for while Thanks again.
    Qt Code:
    1. QDataStream &operator >>(QDataStream &in, PID &pid)
    2. {
    3. double kp;
    4. double ki;
    5. double kd;
    6. in >> kp >> ki >> kd;
    7. pid.setKp(kp);
    8. pid.setKi(ki);
    9. pid.setKd(kd);
    10. return in;
    11. }
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Replies: 3
    Last Post: 29th January 2014, 14:23
  2. no match fo 'operator[]='
    By jeff28 in forum Qt Programming
    Replies: 1
    Last Post: 16th August 2012, 09:53
  3. no match for 'operator=' in...
    By toss in forum Newbie
    Replies: 2
    Last Post: 14th April 2010, 00:08
  4. Qt QDataStream supports data types
    By LoginFailed in forum Qt Programming
    Replies: 2
    Last Post: 30th December 2009, 08:41
  5. No match for operator>>
    By Salazaar in forum Newbie
    Replies: 18
    Last Post: 12th June 2007, 17:48

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.