[solved]QXmlStreamWriter "setDevice(...)" not working
-
wrote on 1 Oct 2010, 12:31 last edited by
I have a problem with the setDevice function of QXmlStreamWriter.
If I do (like it is posted in the QT doc):
@
QByteArray ba;
QBuffer buffer( &ba );
QXmlStreamWriter xml_writer;
xml_writer.setDevice( &buffer );xml_writer.writeStartDocument();
xml_writer.writeDTD("<!DOCTYPE xbel>");
xml_writer.writeStartElement("Element");
xml_writer.writeAttribute("version", "1.0");
xml_writer.writeEndDocument();
QString xml_file( ba );
@I get an empty xml_file string (also the bytearray ba is empty).
If I do:
@
QByteArray ba;
//QBuffer buffer( &ba );
QXmlStreamWriter xml_writer( &ba );
//xml_writer.setDevice( &buffer );
....
@I get the xml message in the bytearray and string.
What do I do wrong?
[edit: mark up code, Tobias Hunger]
-
wrote on 1 Oct 2010, 14:04 last edited by
i think you have to call buffer.open(QIODevice::WriteOnly). Have you tried this already?
-
wrote on 6 Oct 2010, 07:00 last edited by
Argh, of course that's the problem!! Thank you!
This is what happens if you write test routines in existing projects...
1/3