qt, refactor: Fix 'pixmap is deprecated' warnings

This commit is contained in:
Hennadii Stepanov
2020-08-09 17:55:34 +03:00
parent b02264cb5d
commit fa5749c805
4 changed files with 36 additions and 9 deletions

View File

@@ -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