PDA

View Full Version : How to get QByteArray from QString in Qt3



joseph
5th September 2007, 06:10
Hi,


How to get QByteArray from QString object in Qt3..??



thanks in advance.

marcel
5th September 2007, 06:14
You could try QString::local8Bit().
But depends what you want to do with the byte array.
You could also use QString::utf8, but really, depends on your encoding.

Regards

null_pointer
5th September 2007, 09:23
this might work as well...


QStringList string("some text");
QByteArray bytearray;
QDataStream stream( bytearray, IO_ReadWrite );
stream << string.latin1();