diff options
author | Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> | 2020-08-09 19:53:25 +0300 |
---|---|---|
committer | Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> | 2020-08-26 20:22:42 +0300 |
commit | c2f4e5ea1d6f01713ac69aaf6018884028aa55bd (patch) | |
tree | e33da95f6e8c16451313567cb2aec3a3a45a7b42 /src/qt/guiutil.h | |
parent | 8e12d6996116e786e928077b22d9f47cee27319e (diff) | |
download | bitcoin-c2f4e5ea1d6f01713ac69aaf6018884028aa55bd.tar.xz |
qt, refactor: Fix 'split is deprecated' warnings
Diffstat (limited to 'src/qt/guiutil.h')
-rw-r--r-- | src/qt/guiutil.h | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/qt/guiutil.h b/src/qt/guiutil.h index 47145d6f85..c976b4b4bb 100644 --- a/src/qt/guiutil.h +++ b/src/qt/guiutil.h @@ -320,6 +320,27 @@ namespace GUIUtil bool HasPixmap(const QLabel* label); QImage GetImage(const QLabel* label); + /** + * Splits the string into substrings wherever separator occurs, and returns + * the list of those strings. Empty strings do not appear in the result. + * + * QString::split() signature differs in different Qt versions: + * - QString::SplitBehavior is deprecated since Qt 5.15 + * - Qt::SplitBehavior was introduced in Qt 5.14 + * If {QString|Qt}::SkipEmptyParts behavior is required, use this + * function instead of QString::split(). + */ + template <typename SeparatorType> + QStringList SplitSkipEmptyParts(const QString& string, const SeparatorType& separator) + { + #if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)) + return string.split(separator, Qt::SkipEmptyParts); + #else + return string.split(separator, QString::SkipEmptyParts); + #endif + } + + } // namespace GUIUtil #endif // BITCOIN_QT_GUIUTIL_H |