The PySide.QtCore.QUrl class provides a convenient interface for working with URLs.
It can parse and construct URLs in both encoded and unencoded form. PySide.QtCore.QUrl also has support for internationalized domain names (IDNs).
The most common way to use PySide.QtCore.QUrl is to initialize it via the constructor by passing a PySide.QtCore.QString . Otherwise, PySide.QtCore.QUrl.setUrl() and PySide.QtCore.QUrl.setEncodedUrl() can also be used.
URLs can be represented in two forms: encoded or unencoded. The unencoded representation is suitable for showing to users, but the encoded representation is typically what you would send to a web server. For example, the unencoded URL “http://bühler.example.com” would be sent to the server as “http://xn–bhler-kva.example.com/List%20of%20applicants.xml”.
A URL can also be constructed piece by piece by calling PySide.QtCore.QUrl.setScheme() , PySide.QtCore.QUrl.setUserName() , PySide.QtCore.QUrl.setPassword() , PySide.QtCore.QUrl.setHost() , PySide.QtCore.QUrl.setPort() , PySide.QtCore.QUrl.setPath() , PySide.QtCore.QUrl.setEncodedQuery() and PySide.QtCore.QUrl.setFragment() . Some convenience functions are also available: PySide.QtCore.QUrl.setAuthority() sets the user name, password, host and port. PySide.QtCore.QUrl.setUserInfo() sets the user name and password at once.
Call PySide.QtCore.QUrl.isValid() to check if the URL is valid. This can be done at any point during the constructing of a URL.
Constructing a query is particularly convenient through the use of PySide.QtCore.QUrl.setQueryItems() , PySide.QtCore.QUrl.addQueryItem() and PySide.QtCore.QUrl.removeQueryItem() . Use PySide.QtCore.QUrl.setQueryDelimiters() to customize the delimiters used for generating the query string.
For the convenience of generating encoded URL strings or query strings, there are two static functions called PySide.QtCore.QUrl.fromPercentEncoding() and PySide.QtCore.QUrl.toPercentEncoding() which deal with percent encoding and decoding of QStrings.
Calling PySide.QtCore.QUrl.isRelative() will tell whether or not the URL is relative. A relative URL can be resolved by passing it as argument to PySide.QtCore.QUrl.resolved() , which returns an absolute URL. PySide.QtCore.QUrl.isParentOf() is used for determining whether one URL is a parent of another.
PySide.QtCore.QUrl.fromLocalFile() constructs a PySide.QtCore.QUrl by parsing a local file path. PySide.QtCore.QUrl.toLocalFile() converts a URL to a local file path.
The human readable representation of the URL is fetched with PySide.QtCore.QUrl.toString() . This representation is appropriate for displaying a URL to a user in unencoded form. The encoded form however, as returned by PySide.QtCore.QUrl.toEncoded() , is for internal use, passing to web servers, mail clients and so on.
PySide.QtCore.QUrl conforms to the URI specification from RFC 3986 (Uniform Resource Identifier: Generic Syntax), and includes scheme extensions from RFC 1738 (Uniform Resource Locators). Case folding rules in PySide.QtCore.QUrl conform to RFC 3491 (Nameprep: A Stringprep Profile for Internationalized Domain Names (IDN)).
Follow these rules to avoid erroneous character conversion when dealing with URLs and strings:
- When creating an PySide.QtCore.QString to contain a URL from a PySide.QtCore.QByteArray or a char*, always use QString.fromUtf8() .
- Favor the use of QUrl.fromEncoded() and QUrl.toEncoded() instead of PySide.QtCore.QUrl (string) and QUrl.toString() when converting a PySide.QtCore.QUrl to or from a string.
Parameters: |
|
---|
Return type: | PyObject |
---|
Return type: | PyObject |
---|
Parameters: |
|
---|
Parameters: |
|
---|
Parameters: | key – PySide.QtCore.QByteArray |
---|---|
Return type: |
Parameters: | key – unicode |
---|---|
Return type: | list of strings |
Return type: | unicode |
---|
Return type: | PySide.QtCore.QByteArray |
---|
Return type: | PySide.QtCore.QByteArray |
---|
Return type: | PySide.QtCore.QByteArray |
---|
Return type: | PySide.QtCore.QByteArray |
---|
Return type: | PySide.QtCore.QByteArray |
---|
Parameters: | key – PySide.QtCore.QByteArray |
---|---|
Return type: | PySide.QtCore.QByteArray |
Return type: |
---|
Return type: | PySide.QtCore.QByteArray |
---|
Return type: | unicode |
---|
Return type: | unicode |
---|
Parameters: | arg__1 – PySide.QtCore.QByteArray |
---|---|
Return type: | unicode |
Parameters: |
|
---|---|
Return type: |
Parameters: | url – PySide.QtCore.QByteArray |
---|---|
Return type: | PySide.QtCore.QUrl |
Parameters: | localfile – unicode |
---|---|
Return type: | PySide.QtCore.QUrl |
Parameters: | arg__1 – PySide.QtCore.QByteArray |
---|---|
Return type: | unicode |
Parameters: | arg__1 – PySide.QtCore.QByteArray |
---|---|
Return type: | unicode |
Parameters: | userInput – unicode |
---|---|
Return type: | PySide.QtCore.QUrl |
Parameters: | key – PySide.QtCore.QByteArray |
---|---|
Return type: | PySide.QtCore.bool |
Return type: | PySide.QtCore.bool |
---|
Return type: | PySide.QtCore.bool |
---|
Parameters: | key – unicode |
---|---|
Return type: | PySide.QtCore.bool |
Return type: | unicode |
---|
Return type: | list of strings |
---|
Return type: | PySide.QtCore.bool |
---|
Return type: | PySide.QtCore.bool |
---|
Parameters: | url – PySide.QtCore.QUrl |
---|---|
Return type: | PySide.QtCore.bool |
Return type: | PySide.QtCore.bool |
---|
Return type: | PySide.QtCore.bool |
---|
Parameters: | url – PySide.QtCore.QUrl |
---|---|
Return type: | PySide.QtCore.bool |
Parameters: | url – PySide.QtCore.QUrl |
---|---|
Return type: | PySide.QtCore.bool |
Parameters: | url – PySide.QtCore.QUrl |
---|---|
Return type: | PySide.QtCore.bool |
Return type: | unicode |
---|
Return type: | unicode |
---|
Return type: | PySide.QtCore.int |
---|
Parameters: | defaultPort – PySide.QtCore.int |
---|---|
Return type: | PySide.QtCore.int |
Parameters: | key – unicode |
---|---|
Return type: | unicode |
Return type: |
---|
Return type: | PySide.QtCore.char |
---|
Return type: | PySide.QtCore.char |
---|
Parameters: | key – PySide.QtCore.QByteArray |
---|
Parameters: | key – unicode |
---|
Parameters: | key – PySide.QtCore.QByteArray |
---|
Parameters: | key – unicode |
---|
Parameters: | relative – PySide.QtCore.QUrl |
---|---|
Return type: | PySide.QtCore.QUrl |
Return type: | unicode |
---|
Parameters: | authority – unicode |
---|
Parameters: | fragment – PySide.QtCore.QByteArray |
---|
Parameters: | host – PySide.QtCore.QByteArray |
---|
Parameters: | password – PySide.QtCore.QByteArray |
---|
Parameters: | path – PySide.QtCore.QByteArray |
---|
Parameters: | query – PySide.QtCore.QByteArray |
---|
Parameters: | query – |
---|
Parameters: |
|
---|
Parameters: | url – PySide.QtCore.QByteArray |
---|
Parameters: | userName – PySide.QtCore.QByteArray |
---|
Parameters: | fragment – unicode |
---|
Parameters: | host – unicode |
---|
Parameters: | arg__1 – list of strings |
---|
Parameters: | password – unicode |
---|
Parameters: | path – unicode |
---|
Parameters: | port – PySide.QtCore.int |
---|
Parameters: |
|
---|
Parameters: | query – |
---|
Parameters: | scheme – unicode |
---|
Parameters: |
|
---|
Parameters: | url – unicode |
---|
Parameters: | userInfo – unicode |
---|
Parameters: | userName – unicode |
---|
Parameters: | other – PySide.QtCore.QUrl |
---|
Parameters: | arg__1 – unicode |
---|---|
Return type: | PySide.QtCore.QByteArray |
Parameters: | options – PySide.QtCore.QUrl.FormattingOptions |
---|---|
Return type: | PySide.QtCore.QByteArray |
Return type: | unicode |
---|
Parameters: |
|
---|---|
Return type: |
Parameters: | arg__1 – unicode |
---|---|
Return type: | PySide.QtCore.QByteArray |
Parameters: | options – PySide.QtCore.QUrl.FormattingOptions |
---|---|
Return type: | unicode |
Return type: | unicode |
---|
Return type: | unicode |
---|
Return type: | unicode |
---|