PDA

View Full Version : Converting QString to char array



srohit24
22nd July 2009, 16:14
Hi

I am using a function that accepts only charcters.

I am using a QString variable to collect all data.

What i need now is that to convert this QString to char array if possible.
Whenever i try to send the QString, i get a error saying

error: cannot convert `QCharRef' to `char' in argument passing

what should i do to convert the QString to a char array??

wagmare
22nd July 2009, 16:21
const char *str;
QString path;
QByteArray ba;
ba = path.toLatin1();
str = ba.data();
printf("the string path will be:%s\n", str);

Lykurg
22nd July 2009, 16:25
QString::toLocal8Bit() -> QByteArray::constData()

EDIT: too late...

srohit24
22nd July 2009, 18:19
thanks for helping me out. :)