2014年03月05日 星期三 09:23
QUrl模块提供了解析和拼装URL的一些方法,可以支持urlencode编码的URL。
The QUrl class provides a convenient interface for working with URLs.
It can parse and construct URLs in both encoded and unencoded form. QUrl also has support for internationalized domain names (IDNs).
编程示例如下:
#include <QCoreApplication> #include <QtCore> int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); auto url=QUrl("http://user:pass@www.exm.cn:9090/index.php?a=1"); qDebug() << url.scheme(); qDebug() << url.host(); qDebug() << url.port(); qDebug() << url.query(); qDebug() << url.path(); url.setHost("www.sina.com"); url.setPort(80); qDebug() << url.toString(); qDebug() << url.toDisplayString(QUrl::RemoveUserInfo); return a.exec(); }
参考资料:
http://qt-project.org/doc/qt-5/qurl.html
Zeuux © 2024
京ICP备05028076号