Data loss when converting from QString to QByteArray
Posted
by SleepyCod
on Stack Overflow
See other posts from Stack Overflow
or by SleepyCod
Published on 2010-05-07T09:45:21Z
Indexed on
2010/05/07
9:48 UTC
Read the original article
Hit count: 212
qt4
I'm using QPlainTextEdit as an HTML editor, saving the data through an HTTP post with QNetworkAccessManager.
I experience data loss when using HTML special characters such as & (ampersand) I'm building a POST request with a QByteArray (as mentioned in the docs).
QByteArray postData;
QMapIterator<QString, QString> i(params);
while(i.hasNext()) {
i.next();
postData
.append(i.key().toUtf8())
.append("=")
.append(i.value().toUtf8())
.append("&");
}
postData.remove(postData.length()-1, 1);
//Do request
QNetworkRequest postRequest = QNetworkRequest(res);
oManager.post(postRequest, postData);
© Stack Overflow or respective owner