qcam: Fix compilation with Qt v5.15.0

Starting from Qt v5.15.0, the QTextStreamFunctions::fixed function
used to configure formatting on QTextStream is deprecated in favour of
Qt::fixed. This causes a compilation error:

  ../src/qcam/main_window.cpp:634:16: error: ‘QTextStream& QTextStreamFunctions::fixed(QTextStream&)’ is deprecated: Use Qt::fixed [-Werror=deprecated-declarations]
    634 |   << "fps:" << fixed << qSetRealNumberPrecision(2) << fps;
        |                ^~~~~

Fix it by using Qt::fixed, and provide backward compatibility with Qt
versions older than v5.14.0 that didn't provide Qt::fixed.

Signed-off-by: Peter Seiderer <ps.report@gmx.net>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Tested-by: Kieran Bingham <kieran.bingham@ideasonboard.com> # 5.12.8
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
This commit is contained in:
Peter Seiderer 2020-06-07 18:56:55 +02:00 committed by Laurent Pinchart
parent 6781f8b463
commit 8823461d80

View file

@ -31,6 +31,16 @@
using namespace libcamera;
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
/*
* Qt::fixed was introduced in v5.14, and ::fixed deprecated in v5.15. Allow
* usage of Qt::fixed unconditionally.
*/
namespace Qt {
constexpr auto fixed = ::fixed;
} /* namespace Qt */
#endif
/**
* \brief Custom QEvent to signal capture completion
*/
@ -631,7 +641,7 @@ void MainWindow::processViewfinder(FrameBuffer *buffer)
<< QString("seq: %1").arg(metadata.sequence, 6, 10, QLatin1Char('0'))
<< "bytesused:" << metadata.planes[0].bytesused
<< "timestamp:" << metadata.timestamp
<< "fps:" << fixed << qSetRealNumberPrecision(2) << fps;
<< "fps:" << Qt::fixed << qSetRealNumberPrecision(2) << fps;
/* Render the frame on the viewfinder. */
viewfinder_->render(buffer, &mappedBuffers_[buffer]);