Hello,
Do you know what's the fastest and lightest way to convert a QString to a TDesC?
I need it in my project and the descriptor stuff is (sometimes) a bit confusing.
There are a few way, e.g.:
(my project always uses a 13 letters QString, you can replace 13 with qstring.length() for other cases)
//variant 1:
TPtrC16 tdesc(reinterpret_cast<const TText*>(qstring.constData()));
//variant 2:
RBuf tdesc;
tdesc.CreateL(13);
for (int i=0 ; i< length ; i++)
{
char letter = qstring.at (i).toAscii ();
tdesc[i]=letter;
}
//variant 3:
RBuf tdesc;
tdesc.CreateL(13);
tdesc=(const TUint16 *)qstring.utf16();
//variant 4:
TBuf16<13> tdesc;
tdesc=(const TUint16 *)qstring.utf16();