|
|
On Friday 31 August 2007, Vahe Avedissian wrote:
> What am I missing? It's got to be trivially simple to do?
What is the exact code you are using?
This will work:
QString mystring="hallo";
qDebug("%s",mystring.toAscii().data());
-> it creates a temporary byte array, extracts its data and destroys the
temporary data after the command finishes
This will work too:
QString mystring="hallo";
QByteArray myarray=mystring.toAscii();
char *str=myarray.data();
qDebug("%s",str);
-> here the byte array is not temporary, so its data is guaranteed to exist
for a while (until the byte array is destroyed or changed)
This will NOT work:
QString mystring="hallo";
char *str=mystring.toAscii().data();
qDebug("%s",str);
-> it creates a temporary byte array, extracts its data, then destroys the
temporary object, loses the data, and finally tries to display the lost
data
Konrad
|
|