QUrl::host() returns an unescapped (ie. unencoded) IPv6 address literal, as it should.
QUrl::setHost() does not escape the IPv6 address before re-inserting it back into QUrl string.
int main() { QUrl u( "http://[::1]:8080/test" ); qDebug( "1. host: %s", qPrintable( u.host())); qDebug( "1. url: %s", qPrintable( u.toString())); u.setHost( u.host()); qDebug( "2. host: %s", qPrintable( u.host())); qDebug( "2. url: %s", qPrintable( u.toString())); u = QUrl( u.toString()); qDebug( "3. host: %s", qPrintable( u.host())); qDebug( "3. url: %s", qPrintable( u.toString())); return 0; }
returns,
1. host: ::1 1. url: http://[::1]:8080/test 2. host: ::1 2. url: http://::1:8080/test 3. host: 3. url: