diff options
author | Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> | 2020-08-09 17:55:34 +0300 |
---|---|---|
committer | Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> | 2020-08-26 20:17:52 +0300 |
commit | fa5749c805878304c107bcae0ae5ffa401dc7c4d (patch) | |
tree | 00567d46ca9289dcad996d00ab2312432ca12bdb /src/qt/guiutil.cpp | |
parent | b02264cb5dfcef50eec8a6346471cbaa25370e00 (diff) |
qt, refactor: Fix 'pixmap is deprecated' warnings
Diffstat (limited to 'src/qt/guiutil.cpp')
-rw-r--r-- | src/qt/guiutil.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/qt/guiutil.cpp b/src/qt/guiutil.cpp index 72bc4fcddd..70e76f765b 100644 --- a/src/qt/guiutil.cpp +++ b/src/qt/guiutil.cpp @@ -929,4 +929,26 @@ QDateTime StartOfDay(const QDate& date) #endif } +bool HasPixmap(const QLabel* label) +{ +#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)) + return !label->pixmap(Qt::ReturnByValue).isNull(); +#else + return label->pixmap() != nullptr; +#endif +} + +QImage GetImage(const QLabel* label) +{ + if (!HasPixmap(label)) { + return QImage(); + } + +#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)) + return label->pixmap(Qt::ReturnByValue).toImage(); +#else + return label->pixmap()->toImage(); +#endif +} + } // namespace GUIUtil |