I have this problem
83:24: error: non-const lvalue reference to type 'QImage' cannot bind to a temporary of type 'QImage' cameraimplementation.h:23:34: note: passing argument to parameter 'nextImage' here
caused by this code
updateImageData(toQImage());
with
void updateImageData(QImage& nextImage);
QImage toQImage();
How can I solve this other than including a temporary variable.
QImage image = toQImage();
updateImageData(image);
You can't.
The C++ standard does not allow the binding of an anonymous temporary to a reference, although some compilers allow it as an extension. (Binding to a const
reference is allowed.)
Aside from the workaround you already have, if you can change the function to take const QImage&
then that would be better.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With