Ingo Foerster
asked on
QString to TCHAR in QT
Hello,
how I can copy a QString to a TCHAR value of a componet (Dll)?
In VC++ I used:
How it look in QT if m_strDeveloperID is a QString?
how I can copy a QString to a TCHAR value of a componet (Dll)?
In VC++ I used:
_tcsncpy(info.DeveloperID, m_strDeveloperID, 24*sizeof(TCHAR));
//info.DeveloperID = TCHAR
How it look in QT if m_strDeveloperID is a QString?
Ooops, alsmost forgot - the convenience wrapper could just be
TCHAR* QStringToTCHAR(const QString& qs) {
#ifdef _UNICODE
return qs.toStdWString().c_str();
#else
return qs.toStdString().c_str();
#endif
}
// ...
_tcsncpy(info.DeveloperID, QStringToTCHAR(m_strDeveloperID), 24*sizeof(TCHAR));
And, last but not least: see the docs at http://doc.qt.io/qt-5/qstring.html
ASKER
so _tcsncpy is allowed in QT and works on all platforms like Linux, Mac and Windows?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Great and high professional help. Many thanks to jkr.
Open in new window