开发者

How to encode URL parameters in QT?

开发者 https://www.devze.com 2023-01-12 09:21 出处:网络
I have the following URL QString url = \"http://www.gigacooldomainname.com/\" + setName + \"/\" + fileName + \".jpg\"

I have the following URL

QString url = "http://www.gigacooldomainname.com/" + setName + "/" + fileName + ".jpg"

where setName and fileName are QString variables.

I wish to have the following:

QString url = "http://www.gigacooldomainname.com/" + QUrlParameter::encode(setName) + "/" + QUrlParameter::encode(fileName) + ".jpg"

Unfortunately there is not such QUrlParameter class or encode method.

I know I can write one by myself but was curious if there is already an existing solution in QT4.

I am also not int开发者_运维技巧erested in Q3Url::encode solution since I don't have the Q3Url headers.


Use QUrl::toPercentEncoding (static method ;))


In QML you can use encodeURIComponent(str), it's a standard JS function that is supported by QML.

0

精彩评论

暂无评论...
验证码 换一张
取 消