From 552d0fe072a79cc66928782bebbb16a6c9022316 Mon Sep 17 00:00:00 2001 From: Gary Wang Date: Mon, 1 Mar 2021 13:11:17 +0800 Subject: [PATCH] fix: compat for older Qt (lower than 5.13) --- app/graphicsview.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/app/graphicsview.cpp b/app/graphicsview.cpp index ce64369..dcc6009 100644 --- a/app/graphicsview.cpp +++ b/app/graphicsview.cpp @@ -9,6 +9,13 @@ #include #include +// TODO: remove this once we drop older Qt support. +#if QT_VERSION_CHECK(5, 13, 0) +#define COMPAT_CONSTCOLOR constexpr +#else +#define COMPAT_CONSTCOLOR const +#endif + GraphicsView::GraphicsView(QWidget *parent) : QGraphicsView (parent) { @@ -303,8 +310,8 @@ void GraphicsView::setCheckerboardEnabled(bool enabled, bool invertColor) QPixmap tilePixmap(0x20, 0x20); tilePixmap.fill(invertColor ? QColor(220, 220, 220, 170) : QColor(35, 35, 35, 170)); QPainter tilePainter(&tilePixmap); - constexpr QColor color(45, 45, 45, 170); - constexpr QColor invertedColor(210, 210, 210, 170); + COMPAT_CONSTCOLOR QColor color(45, 45, 45, 170); + COMPAT_CONSTCOLOR QColor invertedColor(210, 210, 210, 170); tilePainter.fillRect(0, 0, 0x10, 0x10, invertColor ? invertedColor : color); tilePainter.fillRect(0x10, 0x10, 0x10, 0x10, invertColor ? invertedColor : color); tilePainter.end();