diff options
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 |