Search code examples
qtstreamwriter

QXmlStreamWriter crashes when I try to write too many items


I am using QXmlStreamWriter to create an xml file with many items. At one point because there are too many elements probably I experience a crash. Is there a way to perform a flush on the stream? How else can I perform the writing so I do not experience a crash?


Solution

  • Found out that QByteArray doesn't support more than 2GB. That's why i had a crash. I used QXmlStreamWriter together with a QByteArray. If I provide the file directly it works fine.

    previous code:

    QByteArray buffer;
    QXmlStreamWriter stream(&buffer);
    

    current code:

    QFile* destFile
    QXmlStreamWriter stream(destFile);