Use QUrl::toPercentEncoding on these (and other places in this file that you do substitution into URLs).  Also you'll probably need to use QUrl::fromEncoded