Best way to construct a CString from QString and vice-versa
-
Is this correct (assuming UNICODE)
QString to CString: given a Qstring called qstring
CString cstring((LPCTSTR)qstring.utf16());
CString to QString: given a CString called cstring
QString qstring((QChar *)cstring.GetBuffer());
or are there better incantations?
Thanks
David -
Hi,
This thread on this forum answers the same question.
-
Are you choosing to use CString or are you stuck with it?
I didn't know what it was, but now that I have looked into it, I would avoid using CString if it can be helped.What constructors does CString provide? What data type does CString::GetBuffer() return? I am pretty sure it does not return a QChar buffer.
-
For quite a long while I'm stuck to 1000's of them.
CString documentation here: https://docs.microsoft.com/en-us/cpp/atl-mfc-shared/using-cstring?view=vs-2019, and
https://docs.microsoft.com/en-us/cpp/atl-mfc-shared/reference/cstringt-class?view=vs-2019David
-
Hi,
This thread on this forum answers the same question.