Qyoto  4.0.5
Qyoto is a C# language binding for Qt
 All Classes Namespaces Functions Variables Typedefs Enumerations Properties
QtCore.QUrl Class Reference

The QUrl class provides a convenient interface for working with URLs. More...

Inheritance diagram for QtCore.QUrl:
Collaboration diagram for QtCore.QUrl:

Public Types

enum  FormattingOption {
  None = 0, RemoveAuthority = 30, RemoveFragment = 128, RemovePassword = 2,
  RemovePath = 32, RemovePort = 8, RemoveQuery = 64, RemoveScheme = 1,
  RemoveUserInfo = 6, StripTrailingSlash = 65536
}
  More...
 
enum  ParsingMode { StrictMode = 1, TolerantMode = 0 }
  More...
 

Public Member Functions

override bool Equals (object o)
 
override int GetHashCode ()
 
 QUrl ()
 
 
 QUrl (QUrl copy)
 
 
 QUrl (string url)
 
 
 QUrl (string url, QUrl.ParsingMode mode)
 
 
virtual void CreateProxy ()
 
new void AddEncodedQueryItem (QByteArray key, QByteArray value)
 
 
new void AddQueryItem (string key, string value)
 
 
new
System.Collections.Generic.List
< QByteArray
AllEncodedQueryItemValues (QByteArray key)
 
 
new
System.Collections.Generic.List
< string > 
AllQueryItemValues (string key)
 
 
new void Clear ()
 
 
new void Detach ()
 
new QByteArray EncodedQueryItemValue (QByteArray key)
 
 
new string ErrorString ()
 
 
new bool HasEncodedQueryItem (QByteArray key)
 
 
new bool HasFragment ()
 
 
new bool HasQuery ()
 
 
new bool HasQueryItem (string key)
 
 
new bool IsDetached ()
 
new bool IsEmpty ()
 
 
new bool IsLocalFile ()
 
 
new bool IsParentOf (QUrl url)
 
 
new bool IsRelative ()
 
 
new bool IsValid ()
 
 
new int Port ()
 
 
new int Port (int defaultPort)
 
 
new string QueryItemValue (string key)
 
 
new sbyte QueryPairDelimiter ()
 
 
new sbyte QueryValueDelimiter ()
 
 
new void RemoveAllEncodedQueryItems (QByteArray key)
 
 
new void RemoveAllQueryItems (string key)
 
 
new void RemoveEncodedQueryItem (QByteArray key)
 
 
new void RemoveQueryItem (string key)
 
 
new QUrl Resolved (QUrl relative)
 
 
new void SetEncodedUrl (QByteArray url)
 
 
new void SetEncodedUrl (QByteArray url, QUrl.ParsingMode mode)
 
 
new void SetPort (int port)
 
 
new void SetQueryDelimiters (sbyte valueDelimiter, sbyte pairDelimiter)
 
 
new void SetUrl (string url)
 
 
new void SetUrl (string url, QUrl.ParsingMode mode)
 
 
new void Swap (QUrl other)
 
 
new QByteArray ToEncoded (QUrl.FormattingOption options=QUrl.FormattingOption.None)
 
 
new string ToLocalFile ()
 
 
override string ToString ()
 
 
new string ToString (QUrl.FormattingOption options=QUrl.FormattingOption.None)
 
 
new string TopLevelDomain ()
 
 
new void Dispose ()
 

Static Public Member Functions

static string FromAce (QByteArray arg1)
 
 
static QUrl FromEncoded (QByteArray url)
 
 
static QUrl FromEncoded (QByteArray url, QUrl.ParsingMode mode)
 
 
static QUrl FromLocalFile (string localfile)
 
 
static string FromPercentEncoding (QByteArray arg1)
 
 
static string FromPunycode (QByteArray arg1)
 
 
static QUrl FromUserInput (string userInput)
 
 
static bool operator!= (QUrl arg1, QUrl arg2)
 
 
static bool operator< (QUrl arg1, QUrl arg2)
 
static bool operator== (QUrl arg1, QUrl arg2)
 
 
static QByteArray ToAce (string arg1)
 
 
static QByteArray ToPercentEncoding (string arg1)
 
 
static QByteArray ToPercentEncoding (string arg1, QByteArray exclude)
 
 
static QByteArray ToPercentEncoding (string arg1, QByteArray exclude, QByteArray include)
 
 
static QByteArray ToPunycode (string arg1)
 
 
static bool operator> (QUrl arg1, QUrl arg2)
 

Protected Member Functions

 QUrl (System.Type dummy)
 

Protected Attributes

SmokeInvocation interceptor
 

Properties

new string Authority [get, set]
 
 
new QByteArray EncodedFragment [get, set]
 
 
new QByteArray EncodedHost [get, set]
 
 
new QByteArray EncodedPassword [get, set]
 
 
new QByteArray EncodedPath [get, set]
 
 
new QByteArray EncodedQuery [get, set]
 
 
new QByteArray EncodedUserName [get, set]
 
 
new string Fragment [get, set]
 
 
new string Host [get, set]
 
 
static
System.Collections.Generic.List
< string > 
IdnWhitelist [get, set]
 
 
new string Password [get, set]
 
 
new string Path [get, set]
 
 
new string Scheme [get, set]
 
 
new string UserInfo [get, set]
 
 
new string UserName [get, set]
 
 
virtual System.IntPtr SmokeObject [get, set]
 

Detailed Description

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).

The most common way to use QUrl is to initialize it via the constructor by passing a QString. Otherwise, setUrl() and 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&#252;hler.example.com/List of applicants.xml" would be sent to the server as "http://xn&ndash;bhler-kva.example.com/List%20of%20applicants.xml&quot;, and this can be verified by calling the toEncoded() function.

A URL can also be constructed piece by piece by calling setScheme(), setUserName(), setPassword(), setHost(), setPort(), setPath(), setEncodedQuery() and setFragment(). Some convenience functions are also available: setAuthority() sets the user name, password, host and port. setUserInfo() sets the user name and password at once.

Call 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 setQueryItems(), addQueryItem() and removeQueryItem(). Use 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 fromPercentEncoding() and toPercentEncoding() which deal with percent encoding and decoding of QStrings.

Calling isRelative() will tell whether or not the URL is relative. A relative URL can be resolved by passing it as argument to resolved(), which returns an absolute URL. isParentOf() is used for determining whether one URL is a parent of another.

fromLocalFile() constructs a QUrl by parsing a local file path. toLocalFile() converts a URL to a local file path.

The human readable representation of the URL is fetched with toString(). This representation is appropriate for displaying a URL to a user in unencoded form. The encoded form however, as returned by toEncoded(), is for internal use, passing to web servers, mail clients and so on.

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 QUrl conform to RFC 3491 (Nameprep: A Stringprep Profile for Internationalized Domain Names (IDN)).

Character Conversions

Follow these rules to avoid erroneous character conversion when dealing with URLs and strings:

When creating an QString to contain a URL from a QByteArray or a char*, always use QString::fromUtf8().

Favor the use of QUrl::fromEncoded() and QUrl::toEncoded() instead of QUrl(string) and QUrl::toString() when converting a QUrl to or from a string.

See also QUrlInfo.

Member Enumeration Documentation

The formatting options define how the URL is formatted when written out as text.

Note that the case folding rules in Nameprep, which QUrl conforms to, require host names to always be converted to lower case, regardless of the Qt::FormattingOptions used.

Enumerator:
None 

The format of the URL is unchanged.

RemoveAuthority 
RemoveFragment 
RemovePassword 

Any password in the URL is removed.

RemovePath 

The URL's path is removed, leaving only the scheme, host address, and port (if present).

RemovePort 

Any specified port is removed from the URL.

RemoveQuery 

The query part of the URL (following a '?' character) is removed.

RemoveScheme 

The scheme is removed from the URL.

RemoveUserInfo 

Any user information in the URL is removed.

StripTrailingSlash 

The trailing slash is removed if one is present.

The parsing mode controls the way QUrl parses strings.

In TolerantMode, the parser corrects the following invalid input:

Spaces and "%20": If an encoded URL contains a space, this will be replaced with "%20". If a decoded URL contains "%20", this will be replaced with a single space before the URL is parsed.

Single "%" characters: Any occurrences of a percent character "%" not followed by exactly two hexadecimal characters (e.g., "13% coverage.html") will be replaced by "%25".

Reserved and unreserved characters: An encoded URL should only contain a few characters as literals; all other characters should be percent-encoded. In TolerantMode, these characters will be automatically percent-encoded where they are not allowed: space / double-quote / "<" / ">" / "[" / "" / "]" / "^" / "`" / "{" / "|" / "}"

Enumerator:
StrictMode 

Only valid URLs are accepted. This mode is useful for general URL validation.

TolerantMode 

QUrl will try to correct some common errors in URLs. This mode is useful when processing URLs entered by users.

Constructor & Destructor Documentation

QtCore.QUrl.QUrl ( System.Type  dummy)
protected
QtCore.QUrl.QUrl ( )

Constructs an empty QUrl object.

QtCore.QUrl.QUrl ( QUrl  copy)

Constructs a copy of other.

QtCore.QUrl.QUrl ( string  url)

Constructs a URL by parsing url. url is assumed to be in human readable representation, with no percent encoding. QUrl will automatically percent encode all characters that are not allowed in a URL. The default parsing mode is TolerantMode.

Example:

QUrl url("http://www.example.com/List of holidays.xml");

// url.toEncoded() == "http://www.example.com/List%20of%20holidays.xml&quot;

To construct a URL from an encoded string, call fromEncoded():

QUrl url = QUrl::fromEncoded("http://qt.nokia.com/List%20of%20holidays.xml&quot;);

See also setUrl(), setEncodedUrl(), fromEncoded(), and TolerantMode.

QtCore.QUrl.QUrl ( string  url,
QUrl.ParsingMode  mode 
)

This is an overloaded function.

Parses the url using the parser mode parsingMode. The default parsing mode is TolerantMode.

See also setUrl().

Member Function Documentation

new void QtCore.QUrl.AddEncodedQueryItem ( QByteArray  key,
QByteArray  value 
)

Inserts the pair key = value into the query string of the URL.

Note: this function does not verify that either key or value are properly encoded. It is the caller's responsibility to ensure that the query delimiters are properly encoded, if any.

This function was introduced in Qt 4.4.

See also addQueryItem() and setQueryDelimiters().

new void QtCore.QUrl.AddQueryItem ( string  key,
string  value 
)

Inserts the pair key = value into the query string of the URL.

The key/value pair is encoded before it is added to the query. The pair is converted into separate strings internally. The key and value is first encoded into UTF-8 and then delimited by the character returned by valueDelimiter(). Each key/value pair is delimited by the character returned by pairDelimiter().

Note: This method does not encode spaces (ASCII 0x20) as plus (+) signs, like HTML forms do. If you need that kind of encoding, you must encode the value yourself and use QUrl::addEncodedQueryItem.

See also addEncodedQueryItem().

new System.Collections.Generic.List<QByteArray> QtCore.QUrl.AllEncodedQueryItemValues ( QByteArray  key)

Returns the a list of query string values whose key is equal to key from the URL.

Note: if the encoded key does not match the encoded version of the query, this function will not work. That is, if the encoded query of this URL is "search=Qt%20Rules", calling this function with key = "%73earch" will return an empty list.

This function was introduced in Qt 4.4.

See also allQueryItemValues(), queryItemValue(), and encodedQueryItemValue().

new System.Collections.Generic.List<string> QtCore.QUrl.AllQueryItemValues ( string  key)

Returns the a list of query string values whose key is equal to key from the URL.

Note: This method does not decode spaces plus (+) signs as spaces (ASCII 0x20), like HTML forms do. If you need that kind of decoding, you must use QUrl::allEncodedQueryItemValues and decode the data yourself.

See also queryItemValue().

new void QtCore.QUrl.Clear ( )

Resets the content of the QUrl. After calling this function, the QUrl is equal to one that has been constructed with the default empty constructor.

virtual void QtCore.QUrl.CreateProxy ( )
virtual
new void QtCore.QUrl.Detach ( )
new void QtCore.QUrl.Dispose ( )
new QByteArray QtCore.QUrl.EncodedQueryItemValue ( QByteArray  key)

Returns the first query string value whose key is equal to key from the URL.

Note: if the encoded key does not match the encoded version of the query, this function will not work. That is, if the encoded query of this URL is "search=Qt%20Rules", calling this function with key = "%73earch" will return an empty string.

This function was introduced in Qt 4.4.

See also queryItemValue() and allQueryItemValues().

override bool QtCore.QUrl.Equals ( object  o)
new string QtCore.QUrl.ErrorString ( )

Returns a text string that explains why an URL is invalid in the case being; otherwise returns an empty string.

This function was introduced in Qt 4.2.

static string QtCore.QUrl.FromAce ( QByteArray  arg1)
static

Returns the Unicode form of the given domain name domain, which is encoded in the ASCII Compatible Encoding (ACE). The result of this function is considered equivalent to domain.

If the value in domain cannot be encoded, it will be converted to QString and returned.

The ASCII Compatible Encoding (ACE) is defined by RFC 3490, RFC 3491 and RFC 3492. It is part of the Internationalizing Domain Names in Applications (IDNA) specification, which allows for domain names (like "example.com") to be written using international characters.

This function was introduced in Qt 4.2.

static QUrl QtCore.QUrl.FromEncoded ( QByteArray  url)
static

Parses input and returns the corresponding QUrl. input is assumed to be in encoded form, containing only ASCII characters.

The URL is parsed using TolerantMode.

See also toEncoded() and setUrl().

static QUrl QtCore.QUrl.FromEncoded ( QByteArray  url,
QUrl.ParsingMode  mode 
)
static

This is an overloaded function.

Parses the URL using parsingMode.

See also toEncoded() and setUrl().

static QUrl QtCore.QUrl.FromLocalFile ( string  localfile)
static

Returns a QUrl representation of localFile, interpreted as a local file. This function accepts paths separated by slashes as well as the native separator for this platform.

This function also accepts paths with a doubled leading slash (or backslash) to indicate a remote file, as in "//servername/path/to/file.txt". Note that only certain platforms can actually open this file using QFile::open().

See also toLocalFile(), isLocalFile(), and QDir::toNativeSeparators().

static string QtCore.QUrl.FromPercentEncoding ( QByteArray  arg1)
static

Returns a decoded copy of input. input is first decoded from percent encoding, then converted from UTF-8 to unicode.

static string QtCore.QUrl.FromPunycode ( QByteArray  arg1)
static

Returns the Punycode decoded representation of pc.

Punycode is a Unicode encoding used for internationalized domain names, as defined in RFC3492. If you want to convert a domain from its ASCII-compatible encoding to the Unicode representation, use fromAce().

static QUrl QtCore.QUrl.FromUserInput ( string  userInput)
static

Returns a valid URL from a user supplied userInput string if one can be deducted. In the case that is not possible, an invalid QUrl() is returned.

Most applications that can browse the web, allow the user to input a URL in the form of a plain string. This string can be manually typed into a location bar, obtained from the clipboard, or passed in via command line arguments.

When the string is not already a valid URL, a best guess is performed, making various web related assumptions.

In the case the string corresponds to a valid file path on the system, a file:// URL is constructed, using QUrl::fromLocalFile().

If that is not the case, an attempt is made to turn the string into a http:// or ftp:// URL. The latter in the case the string starts with 'ftp'. The result is then passed through QUrl's tolerant parser, and in the case or success, a valid QUrl is returned, or else a QUrl().

Examples:

qt.nokia.com becomes http://qt.nokia.com

ftp.qt.nokia.com becomes ftp://ftp.qt.nokia.com

hostname becomes http://hostname

/home/user/test.html becomes file:///home/user/test.html

This function was introduced in Qt 4.6.

override int QtCore.QUrl.GetHashCode ( )
new bool QtCore.QUrl.HasEncodedQueryItem ( QByteArray  key)

Returns true if there is a query string pair whose key is equal to key from the URL.

Note: if the encoded key does not match the encoded version of the query, this function will return false. That is, if the encoded query of this URL is "search=Qt%20Rules", calling this function with key = "%73earch" will return false.

This function was introduced in Qt 4.4.

See also hasQueryItem().

new bool QtCore.QUrl.HasFragment ( )

Returns true if this URL contains a fragment (i.e., if # was seen on it).

This function was introduced in Qt 4.2.

See also fragment() and setFragment().

new bool QtCore.QUrl.HasQuery ( )

Returns true if this URL contains a Query (i.e., if ? was seen on it).

This function was introduced in Qt 4.2.

See also hasQueryItem() and encodedQuery().

new bool QtCore.QUrl.HasQueryItem ( string  key)

Returns true if there is a query string pair whose key is equal to key from the URL.

See also hasEncodedQueryItem().

new bool QtCore.QUrl.IsDetached ( )
new bool QtCore.QUrl.IsEmpty ( )

Returns true if the URL has no data; otherwise returns false.

new bool QtCore.QUrl.IsLocalFile ( )

Returns true if this URL is pointing to a local file path. A URL is a local file path if the scheme is "file".

Note that this function considers URLs with hostnames to be local file paths, even if the eventual file path cannot be opened with QFile::open().

This function was introduced in Qt 4.8.

See also fromLocalFile() and toLocalFile().

new bool QtCore.QUrl.IsParentOf ( QUrl  url)

Returns true if this URL is a parent of childUrl. childUrl is a child of this URL if the two URLs share the same scheme and authority, and this URL's path is a parent of the path of childUrl.

new bool QtCore.QUrl.IsRelative ( )

Returns true if the URL is relative; otherwise returns false. A URL is relative if its scheme is undefined; this function is therefore equivalent to calling scheme().isEmpty().

new bool QtCore.QUrl.IsValid ( )

Returns true if the URL is valid; otherwise returns false.

The URL is run through a conformance test. Every part of the URL must conform to the standard encoding rules of the URI standard for the URL to be reported as valid.

bool checkUrl(const QUrl &url) {

if (!url.isValid()) {

qDebug(QString("Invalid URL: %1").arg(url.toString()));

return false;

}

return true;

}

static bool QtCore.QUrl.operator!= ( QUrl  arg1,
QUrl  arg2 
)
static

Returns true if this URL and the given url are not equal; otherwise returns false.

static bool QtCore.QUrl.operator< ( QUrl  arg1,
QUrl  arg2 
)
static
static bool QtCore.QUrl.operator== ( QUrl  arg1,
QUrl  arg2 
)
static

Returns true if this URL and the given url are equal; otherwise returns false.

static bool QtCore.QUrl.operator> ( QUrl  arg1,
QUrl  arg2 
)
static
new int QtCore.QUrl.Port ( )

Returns the port of the URL, or -1 if the port is unspecified.

See also setPort().

new int QtCore.QUrl.Port ( int  defaultPort)

This is an overloaded function.

Returns the port of the URL, or defaultPort if the port is unspecified.

Example:

QFtp ftp;

ftp.connectToHost(url.host(), url.port(21));

This function was introduced in Qt 4.1.

new string QtCore.QUrl.QueryItemValue ( string  key)

Returns the first query string value whose key is equal to key from the URL.

Note: This method does not decode spaces plus (+) signs as spaces (ASCII 0x20), like HTML forms do. If you need that kind of decoding, you must use QUrl::encodedQueryItemValue and decode the data yourself.

See also allQueryItemValues().

new sbyte QtCore.QUrl.QueryPairDelimiter ( )

Returns the character used to delimit between key-value pairs in the query string of the URL.

new sbyte QtCore.QUrl.QueryValueDelimiter ( )

Returns the character used to delimit between keys and values in the query string of the URL.

new void QtCore.QUrl.RemoveAllEncodedQueryItems ( QByteArray  key)

Removes all the query string pairs whose key is equal to key from the URL.

Note: if the encoded key does not match the encoded version of the query, this function will not work. That is, if the encoded query of this URL is "search=Qt%20Rules", calling this function with key = "%73earch" will do nothing.

This function was introduced in Qt 4.4.

See also removeQueryItem().

new void QtCore.QUrl.RemoveAllQueryItems ( string  key)

Removes all the query string pairs whose key is equal to key from the URL.

See also removeQueryItem().

new void QtCore.QUrl.RemoveEncodedQueryItem ( QByteArray  key)

Removes the first query string pair whose key is equal to key from the URL.

Note: if the encoded key does not match the encoded version of the query, this function will not work. That is, if the encoded query of this URL is "search=Qt%20Rules", calling this function with key = "%73earch" will do nothing.

This function was introduced in Qt 4.4.

See also removeQueryItem() and removeAllQueryItems().

new void QtCore.QUrl.RemoveQueryItem ( string  key)

Removes the first query string pair whose key is equal to key from the URL.

See also removeAllQueryItems().

new QUrl QtCore.QUrl.Resolved ( QUrl  relative)

Returns the result of the merge of this URL with relative. This URL is used as a base to convert relative to an absolute URL.

If relative is not a relative URL, this function will return relative directly. Otherwise, the paths of the two URLs are merged, and the new URL returned has the scheme and authority of the base URL, but with the merged path, as in the following example:

QUrl baseUrl("http://qt.nokia.com/support&quot;);

QUrl relativeUrl("../products/solutions");

qDebug(baseUrl.resolved(relativeUrl).toString());

// prints "http://qt.nokia.com/products/solutions&quot;

Calling resolved() with ".." returns a QUrl whose directory is one level higher than the original. Similarly, calling resolved() with "../.." removes two levels from the path. If relative is "/", the path becomes "/".

See also isRelative().

new void QtCore.QUrl.SetEncodedUrl ( QByteArray  url)

Constructs a URL by parsing the contents of encodedUrl.

encodedUrl is assumed to be a URL string in percent encoded form, containing only ASCII characters.

Use isValid() to determine if a valid URL was constructed.

See also setUrl().

new void QtCore.QUrl.SetEncodedUrl ( QByteArray  url,
QUrl.ParsingMode  mode 
)

Constructs a URL by parsing the contents of encodedUrl using the given parsingMode.

new void QtCore.QUrl.SetPort ( int  port)

Sets the port of the URL to port. The port is part of the authority of the URL, as described in setAuthority().

port must be between 0 and 65535 inclusive. Setting the port to -1 indicates that the port is unspecified.

See also port().

new void QtCore.QUrl.SetQueryDelimiters ( sbyte  valueDelimiter,
sbyte  pairDelimiter 
)

Sets the characters used for delimiting between keys and values, and between key-value pairs in the URL's query string. The default value delimiter is '=' and the default pair delimiter is '&'.

valueDelimiter will be used for separating keys from values, and pairDelimiter will be used to separate key-value pairs. Any occurrences of these delimiting characters in the encoded representation of the keys and values of the query string are percent encoded.

If valueDelimiter is set to '-' and pairDelimiter is '/', the above query string would instead be represented like this:

http://www.example.com/cgi-bin/drawgraph.cgi?type-pie/color-green

Calling this function does not change the delimiters of the current query string. It only affects queryItems(), setQueryItems() and addQueryItems().

new void QtCore.QUrl.SetUrl ( string  url)

Constructs a URL by parsing the contents of url.

url is assumed to be in unicode format, with no percent encoding.

Calling isValid() will tell whether or not a valid URL was constructed.

See also setEncodedUrl().

new void QtCore.QUrl.SetUrl ( string  url,
QUrl.ParsingMode  mode 
)

This is an overloaded function.

Parses url using the parsing mode parsingMode.

See also setEncodedUrl().

new void QtCore.QUrl.Swap ( QUrl  other)

Swaps URL other with this URL. This operation is very fast and never fails.

This function was introduced in Qt 4.8.

static QByteArray QtCore.QUrl.ToAce ( string  arg1)
static

Returns the ASCII Compatible Encoding of the given domain name domain. The result of this function is considered equivalent to domain.

The ASCII-Compatible Encoding (ACE) is defined by RFC 3490, RFC 3491 and RFC 3492. It is part of the Internationalizing Domain Names in Applications (IDNA) specification, which allows for domain names (like "example.com") to be written using international characters.

This function return an empty QByteArra if domain is not a valid hostname. Note, in particular, that IPv6 literals are not valid domain names.

This function was introduced in Qt 4.2.

new QByteArray QtCore.QUrl.ToEncoded ( QUrl.FormattingOption  options = QUrl.FormattingOption.None)

Returns the encoded representation of the URL if it's valid; otherwise an empty QByteArray is returned. The output can be customized by passing flags with options.

The user info, path and fragment are all converted to UTF-8, and all non-ASCII characters are then percent encoded. The host name is encoded using Punycode.

new string QtCore.QUrl.ToLocalFile ( )

Returns the path of this URL formatted as a local file path. The path returned will use forward slashes, even if it was originally created from one with backslashes.

If this URL contains a non-empty hostname, it will be encoded in the returned value in the form found on SMB networks (for example, "//servername/path/to/file.txt").

If this is a relative URL, in Qt 4.x this function returns the path to maintain backward compatability. This will change from 5.0 onwards. Then the path is returned only for URLs where the scheme is "file", and for all other URLs an empty string is returned.

See also fromLocalFile() and isLocalFile().

static QByteArray QtCore.QUrl.ToPercentEncoding ( string  arg1)
static

Returns an encoded copy of input. input is first converted to UTF-8, and all ASCII-characters that are not in the unreserved group are percent encoded. To prevent characters from being percent encoded pass them to exclude. To force characters to be percent encoded pass them to include.

Unreserved is defined as: ALPHA / DIGIT / "-" / "." / "_" / "~"

QByteArray ba = QUrl::toPercentEncoding("{a fishy string?}", "{}", "s");

qDebug(ba.constData());

// prints "{a fi%73hy %73tring%3F}"

static QByteArray QtCore.QUrl.ToPercentEncoding ( string  arg1,
QByteArray  exclude 
)
static

Returns an encoded copy of input. input is first converted to UTF-8, and all ASCII-characters that are not in the unreserved group are percent encoded. To prevent characters from being percent encoded pass them to exclude. To force characters to be percent encoded pass them to include.

Unreserved is defined as: ALPHA / DIGIT / "-" / "." / "_" / "~"

QByteArray ba = QUrl::toPercentEncoding("{a fishy string?}", "{}", "s");

qDebug(ba.constData());

// prints "{a fi%73hy %73tring%3F}"

static QByteArray QtCore.QUrl.ToPercentEncoding ( string  arg1,
QByteArray  exclude,
QByteArray  include 
)
static

Returns an encoded copy of input. input is first converted to UTF-8, and all ASCII-characters that are not in the unreserved group are percent encoded. To prevent characters from being percent encoded pass them to exclude. To force characters to be percent encoded pass them to include.

Unreserved is defined as: ALPHA / DIGIT / "-" / "." / "_" / "~"

QByteArray ba = QUrl::toPercentEncoding("{a fishy string?}", "{}", "s");

qDebug(ba.constData());

// prints "{a fi%73hy %73tring%3F}"

new string QtCore.QUrl.TopLevelDomain ( )

Returns the TLD (Top-Level Domain) of the URL, (e.g. .co.uk, .net). Note that the return value is prefixed with a '.' unless the URL does not contain a valid TLD, in which case the function returns an empty string.

This function was introduced in Qt 4.8.

static QByteArray QtCore.QUrl.ToPunycode ( string  arg1)
static

Returns a uc in Punycode encoding.

Punycode is a Unicode encoding used for internationalized domain names, as defined in RFC3492. If you want to convert a domain name from Unicode to its ASCII-compatible representation, use toAce().

override string QtCore.QUrl.ToString ( )

Returns the human-displayable string representation of the URL. The output can be customized by passing flags with options.

See also FormattingOptions and toEncoded().

new string QtCore.QUrl.ToString ( QUrl.FormattingOption  options = QUrl.FormattingOption.None)

Returns the human-displayable string representation of the URL. The output can be customized by passing flags with options.

See also FormattingOptions and toEncoded().

Member Data Documentation

SmokeInvocation QtCore.QUrl.interceptor
protected

Property Documentation

new string QtCore.QUrl.Authority
getset

Returns the authority of the URL if it is defined; otherwise an empty string is returned.

Sets the authority of the URL to authority.

The authority of a URL is the combination of user info, a host name and a port. All of these elements are optional; an empty authority is therefore valid.

The user info and host are separated by a '@', and the host and port are separated by a ':'. If the user info is empty, the '@' must be omitted; although a stray ':' is permitted if the port is empty.

The following example shows a valid authority string:

new QByteArray QtCore.QUrl.EncodedFragment
getset

Returns the fragment of the URL if it is defined; otherwise an empty string is returned. The returned value will have its non-ASCII and other control characters percent-encoded, as in toEncoded().

This function was introduced in Qt 4.4.

Sets the URL's fragment to the percent-encoded fragment. The fragment is the last part of the URL, represented by a '#' followed by a string of characters. It is typically used in HTTP for referring to a certain link or point on a page:

The fragment is sometimes also referred to as the URL "reference".

Passing an argument of QByteArray() (a null QByteArray) will unset the fragment. Passing an argument of QByteArray("") (an empty but not null QByteArray) will set the fragment to an empty string (as if the original URL had a lone "#").

This function was introduced in Qt 4.4.

new QByteArray QtCore.QUrl.EncodedHost
getset

Returns the host part of the URL if it is defined; otherwise an empty string is returned.

Note: encodedHost() does not return percent-encoded hostnames. Instead, the ACE-encoded (bare ASCII in Punycode encoding) form will be returned for any non-ASCII hostname.

This function is equivalent to calling QUrl::toAce() on the return value of host().

This function was introduced in Qt 4.4.

Sets the URL's host to the ACE- or percent-encoded host. The host is part of the user info element in the authority of the URL, as described in setAuthority().

This function was introduced in Qt 4.4.

new QByteArray QtCore.QUrl.EncodedPassword
getset

Returns the password of the URL if it is defined; otherwise an empty string is returned. The returned value will have its non-ASCII and other control characters percent-encoded, as in toEncoded().

This function was introduced in Qt 4.4.

Sets the URL's password to the percent-encoded password. The password is part of the user info element in the authority of the URL, as described in setUserInfo().

Note: this function does not verify that password is properly encoded. It is the caller's responsibility to ensure that the any delimiters (such as colons or slashes) are properly encoded.

This function was introduced in Qt 4.4.

new QByteArray QtCore.QUrl.EncodedPath
getset

Returns the path of the URL if it is defined; otherwise an empty string is returned. The returned value will have its non-ASCII and other control characters percent-encoded, as in toEncoded().

This function was introduced in Qt 4.4.

Sets the URL's path to the percent-encoded path. The path is the part of the URL that comes after the authority but before the query string.

For non-hierarchical schemes, the path will be everything following the scheme declaration, as in the following example:

Note: this function does not verify that path is properly encoded. It is the caller's responsibility to ensure that the any delimiters (such as '?' and '#') are properly encoded.

This function was introduced in Qt 4.4.

new QByteArray QtCore.QUrl.EncodedQuery
getset

Returns the query string of the URL in percent encoded form.

Sets the query string of the URL to query. The string is inserted as-is, and no further encoding is performed when calling toEncoded().

This function is useful if you need to pass a query string that does not fit into the key-value pattern, or that uses a different scheme for encoding special characters than what is suggested by QUrl.

Passing a value of QByteArray() to query (a null QByteArray) unsets the query completely. However, passing a value of QByteArray("") will set the query to an empty value, as if the original URL had a lone "?".

new QByteArray QtCore.QUrl.EncodedUserName
getset

Returns the user name of the URL if it is defined; otherwise an empty string is returned. The returned value will have its non-ASCII and other control characters percent-encoded, as in toEncoded().

This function was introduced in Qt 4.4.

Sets the URL's user name to the percent-encoded userName. The userName is part of the user info element in the authority of the URL, as described in setUserInfo().

Note: this function does not verify that userName is properly encoded. It is the caller's responsibility to ensure that the any delimiters (such as colons or slashes) are properly encoded.

This function was introduced in Qt 4.4.

new string QtCore.QUrl.Fragment
getset

Returns the fragment of the URL.

Sets the fragment of the URL to fragment. The fragment is the last part of the URL, represented by a '#' followed by a string of characters. It is typically used in HTTP for referring to a certain link or point on a page:

The fragment is sometimes also referred to as the URL "reference".

Passing an argument of QString() (a null QString) will unset the fragment. Passing an argument of QString("") (an empty but not null QString) will set the fragment to an empty string (as if the original URL had a lone "#").

new string QtCore.QUrl.Host
getset

Returns the host of the URL if it is defined; otherwise an empty string is returned.

Sets the host of the URL to host. The host is part of the authority.

System.Collections.Generic.List<string> QtCore.QUrl.IdnWhitelist
staticgetset

Returns the current whitelist of top-level domains that are allowed to have non-ASCII characters in their compositions.

See setIdnWhitelist() for the rationale of this list.

This function was introduced in Qt 4.2.

Sets the whitelist of Top-Level Domains (TLDs) that are allowed to have non-ASCII characters in domains to the value of list.

Note that if you call this function, you need to do so \em before you start any threads that might access idnWhitelist().

Qt has comes a default list that contains the Internet top-level domains that have published support for Internationalized Domain Names (IDNs) and rules to guarantee that no deception can happen between similarly-looking characters (such as the Latin lowercase letter 'a' and the Cyrillic equivalent, which in most fonts are visually identical).

This list is periodically maintained, as registrars publish new rules.

This function is provided for those who need to manipulate the list, in order to add or remove a TLD. It is not recommended to change its value for purposes other than testing, as it may expose users to security risks.

This function was introduced in Qt 4.2.

new string QtCore.QUrl.Password
getset

Returns the password of the URL if it is defined; otherwise an empty string is returned.

Sets the URL's password to password. The password is part of the user info element in the authority of the URL, as described in setUserInfo().

new string QtCore.QUrl.Path
getset

Returns the path of the URL.

Sets the path of the URL to path. The path is the part of the URL that comes after the authority but before the query string.

For non-hierarchical schemes, the path will be everything following the scheme declaration, as in the following example:

new string QtCore.QUrl.Scheme
getset

Returns the scheme of the URL. If an empty string is returned, this means the scheme is undefined and the URL is then relative.

Sets the scheme of the URL to scheme. As a scheme can only contain ASCII characters, no conversion or encoding is done on the input.

The scheme describes the type (or protocol) of the URL. It's represented by one or more ASCII characters at the start the URL, and is followed by a ':'. The following example shows a URL where the scheme is "ftp":

The scheme can also be empty, in which case the URL is interpreted as relative.

virtual System.IntPtr QtCore.QUrl.SmokeObject
getset
new string QtCore.QUrl.UserInfo
getset

Returns the user info of the URL, or an empty string if the user info is undefined.

Sets the user info of the URL to userInfo. The user info is an optional part of the authority of the URL, as described in setAuthority().

The user info consists of a user name and optionally a password, separated by a ':'. If the password is empty, the colon must be omitted. The following example shows a valid user info string:

new string QtCore.QUrl.UserName
getset

Returns the user name of the URL if it is defined; otherwise an empty string is returned.

Sets the URL's user name to userName. The userName is part of the user info element in the authority of the URL, as described in setUserInfo().