tags:

views:

298

answers:

1

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);
A: 

I'm not an expert in network programming in Qt, but your code seems like reinventing the wheel. Check out QUrl class - it has setters for query parameters, host, scheme, etc. and can be used directly through QNetworkRequest.

chalup
I've finally found the solution with QUrl and toEncoded() function thanks for your answer.
SleepyCod