Hi There, can comeone give me a hint on how to use the QString::data() ?
As I know from the Documentation Qt stores strings internally as Unicode. So my question is: Can I use the Pointer returned by data() as a pointer to WCHAR (wchar_t) ?
static void toWideChar(const QString& qsIn, LPWSTR* wideCharOut)
{
Q_ASSERT(!qsIn.isEmpty());
*wideCharOut = (LPWSTR)qsIn.data();
}
static void toWideChar(const QString& qsIn, LPWSTR* wideCharOut)
{
Q_ASSERT(!qsIn.isEmpty());
*wideCharOut = (LPWSTR)qsIn.data();
}
To copy to clipboard, switch view to plain text mode
I found in qstring.h the ushort data pointer:
struct Data {
QBasicAtomicInt ref;
int alloc, size;
ushort *data;
ushort clean : 1;
ushort simpletext : 1;
ushort righttoleft : 1;
ushort asciiCache : 1;
ushort capacity : 1;
ushort reserved : 11;
ushort array[1];
};
struct Data {
QBasicAtomicInt ref;
int alloc, size;
ushort *data;
ushort clean : 1;
ushort simpletext : 1;
ushort righttoleft : 1;
ushort asciiCache : 1;
ushort capacity : 1;
ushort reserved : 11;
ushort array[1];
};
To copy to clipboard, switch view to plain text mode
This Pointer will be returned as a reinterpretet QChar Pointer:
{ return reinterpret_cast<const
QChar*>
(d
->data
);
}
inline const QChar *QString::data() const
{ return reinterpret_cast<const QChar*>(d->data); }
To copy to clipboard, switch view to plain text mode
All other attempts (i.e. toWCharArray()) seem to copy all the content and this is what I try to avoid.
Any Commtents (however, even good practive-hints) ? Thanks.
Bookmarks