Convenience functions

This commit is contained in:
Moritz Bunkus 2012-04-09 15:09:48 +02:00
parent 9002e64e1a
commit 7918fa30cf

View File

@ -11,9 +11,30 @@
Written by Moritz Bunkus <moritz@bunkus.org>.
*/
#ifndef __MTX_COMMON_QTCOMMON_H
#define __MTX_COMMON_QTCOMMON_H
#ifndef MTX_COMMON_QT_H
#define MTX_COMMON_QT_H
#define Q(s) QString::fromUtf8(s)
#define Q(s) to_qs(s)
#define QY(s) to_qs(Y(s))
#endif // __MTX_COMMON_QTCOMMON_H
inline QString
to_qs(std::string const &source) {
return QString::fromUtf8(source.c_str());
}
inline QString
to_qs(std::wstring const &source) {
return QString::fromStdWString(source);
}
inline std::string
to_utf8(QString const &source) {
return std::string{ source.toUtf8() };
}
inline std::wstring
to_wide(QString const &source) {
return source.toStdWString();
}
#endif // MTX_COMMON_QT_H