Nominate our 2022 Qt Champions!

Problem with QUrlQuery::toString(QUrl::FullyEncoded) (.toUtf8()) ,with character '+'

  • Hi,
    I have the following code :

    QUrlQuery postData;
    QByteArray b=postdata.toString(QUrl::FullyEncoded) .toUtf8(); 
    m_reponse = m_pNetManager->post(requete,  postData.toString(QUrl::FullyEncoded).toUtf8());

    When objet or message contains the character '+' ,the variable b contains this character not encoded (not as %) and the webservices php (api rest) receive a space character instead of '+'.I think that postData.toString(QUrl::FullyEncoded) has a bug because the character '+' must be encoded like '%n'....

  • I have fixed it with


    but it 'is a bug of the method QUrlQuery::toString(QUrl::FullyEncoded),that should encode the character '+' as "%2B"...
    my problem is solved.

  • Hi! This bug has been reported as QTBUG-50001.

  • OK thanks Wieland,
    I had this problem with version Qt 5.3.2 compiled from sources for windows, with 5.4.1 for linux and with 5.4.2 for MacOSX.

Log in to reply