From 8823461d80ad64b972bc6d568c47aba50bed26a4 Mon Sep 17 00:00:00 2001 From: Peter Seiderer Date: Sun, 7 Jun 2020 18:56:55 +0200 Subject: qcam: Fix compilation with Qt v5.15.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Laurent Pinchart Reviewed-by: Kieran Bingham Tested-by: Kieran Bingham # 5.12.8 Signed-off-by: Laurent Pinchart --- src/qcam/main_window.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'src/qcam') diff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp index 7de08957..2960259f 100644 --- a/src/qcam/main_window.cpp +++ b/src/qcam/main_window.cpp @@ -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]); -- cgit v1.2.1