Add qstringFromStdStringView()

This commit is contained in:
Martchus 2021-03-20 21:02:37 +01:00
parent 25062fcf01
commit abb9f5790a
2 changed files with 8 additions and 2 deletions

View File

@ -9,8 +9,8 @@ set(META_APP_URL "https://github.com/${META_APP_AUTHOR}/${META_PROJECT_NAME}")
set(META_APP_DESCRIPTION
"Common Qt related C++ classes and routines used by my applications such as dialogs, widgets and models")
set(META_VERSION_MAJOR 6)
set(META_VERSION_MINOR 3)
set(META_VERSION_PATCH 4)
set(META_VERSION_MINOR 4)
set(META_VERSION_PATCH 0)
set(META_APP_VERSION ${META_VERSION_MAJOR}.${META_VERSION_MINOR}.${META_VERSION_PATCH})
project(${META_PROJECT_NAME})

View File

@ -6,6 +6,7 @@
#include <QString>
#include <string>
#include <string_view>
namespace QtUtilities {
@ -36,6 +37,11 @@ inline QString fromNativeFileName(const std::string &nativeFileName)
#endif
}
inline QString qstringFromStdStringView(std::string_view stringView)
{
return QString::fromUtf8(stringView.data(), static_cast<QString::size_type>(stringView.size()));
}
} // namespace QtUtilities
#endif // QT_UTILITIES_CONVERSION_H