Struct qt_core::QUrl

source ·
#[repr(C)]
pub struct QUrl { /* private fields */ }
Expand description

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

C++ class: QUrl.

C++ documentation:

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() 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/List of applicants.xml" 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 setScheme(), setUserName(), setPassword(), setHost(), setPort(), setPath(), setQuery() 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. If isValid() returns false, you should clear() the URL before proceeding, or start over by parsing a new URL with setUrl().

Constructing a query is particularly convenient through the use of the QUrlQuery class and its methods QUrlQuery::setQueryItems(), QUrlQuery::addQueryItem() and QUrlQuery::removeQueryItem(). Use QUrlQuery::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 QString objects.

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. Both forms are technically correct and represent the same URL unambiguously -- in fact, passing either form to QUrl's constructor or to setUrl() will yield the same QUrl object.

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)). It is also compatible with the file URI specification from freedesktop.org, provided that the locale encodes file names using UTF-8 (required by IDN).

Relative URLs vs Relative Paths

Calling isRelative() will return whether or not the URL is relative. A relative URL has no scheme. For example:

qDebug() << QUrl(“main.qml”).isRelative(); // true: no scheme qDebug() << QUrl(“qml/main.qml”).isRelative(); // true: no scheme qDebug() << QUrl(“file:main.qml”).isRelative(); // false: has “file” scheme qDebug() << QUrl(“file:qml/main.qml”).isRelative(); // false: has “file” scheme

Notice that a URL can be absolute while containing a relative path, and vice versa:

// Absolute URL, relative path QUrl url(“file:file.txt”); qDebug() << url.isRelative(); // false: has “file” scheme qDebug() << QDir::isAbsolutePath(url.path()); // false: relative path

// Relative URL, absolute path url = QUrl(“/home/user/file.txt”); qDebug() << url.isRelative(); // true: has no scheme qDebug() << QDir::isAbsolutePath(url.path()); // true: absolute path

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

Error checking

QUrl is capable of detecting many errors in URLs while parsing it or when components of the URL are set with individual setter methods (like setScheme(), setHost() or setPath()). If the parsing or setter function is successful, any previously recorded error conditions will be discarded.

By default, QUrl setter methods operate in QUrl::TolerantMode, which means they accept some common mistakes and mis-representation of data. An alternate method of parsing is QUrl::StrictMode, which applies further checks. See QUrl::ParsingMode for a description of the difference of the parsing modes.

QUrl only checks for conformance with the URL specification. It does not try to verify that high-level protocol URLs are in the format they are expected to be by handlers elsewhere. For example, the following URIs are all considered valid by QUrl, even if they do not make sense when used:

  • "http:/filename.html"
  • "mailto://example.com"

When the parser encounters an error, it signals the event by making isValid() return false and toString() / toEncoded() return an empty string. If it is necessary to show the user the reason why the URL failed to parse, the error condition can be obtained from QUrl by calling errorString(). Note that this message is highly technical and may not make sense to end-users.

QUrl is capable of recording only one error condition. If more than one error is found, it is undefined which error is reported.

Character Conversions

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

Implementations§

source§

impl QUrl

source

pub unsafe fn adjusted( &self, options: impl CastInto<Ref<QUrlTwoFlagsOfUrlFormattingOptionComponentFormattingOption>> ) -> CppBox<QUrl>

Returns an adjusted version of the URL. The output can be customized by passing flags with options.

Calls C++ function: QUrl QUrl::adjusted(QUrlTwoFlags<QUrl::UrlFormattingOption, QUrl::ComponentFormattingOption> options) const.

C++ documentation:

Returns an adjusted version of the URL. The output can be customized by passing flags with options.

The encoding options from QUrl::ComponentFormattingOption don't make much sense for this method, nor does QUrl::PreferLocalFile.

This is always equivalent to QUrl(url.toString(options)).

This function was introduced in Qt 5.2.

See also FormattingOptions, toEncoded(), and toString().

source

pub unsafe fn authority_1a( &self, options: QFlags<ComponentFormattingOption> ) -> CppBox<QString>

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

Calls C++ function: QString QUrl::authority(QFlags<QUrl::ComponentFormattingOption> options = …) const.

C++ documentation:

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

This function returns an unambiguous value, which may contain that characters still percent-encoded, plus some control sequences not representable in decoded form in QString.

The options argument controls how to format the user info component. The value of QUrl::FullyDecoded is not permitted in this function. If you need to obtain fully decoded data, call userName(), password(), host() and port() individually.

See also setAuthority(), userInfo(), userName(), password(), host(), and port().

source

pub unsafe fn authority_0a(&self) -> CppBox<QString>

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

Calls C++ function: QString QUrl::authority() const.

C++ documentation:

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

This function returns an unambiguous value, which may contain that characters still percent-encoded, plus some control sequences not representable in decoded form in QString.

The options argument controls how to format the user info component. The value of QUrl::FullyDecoded is not permitted in this function. If you need to obtain fully decoded data, call userName(), password(), host() and port() individually.

See also setAuthority(), userInfo(), userName(), password(), host(), and port().

source

pub unsafe fn clear(&self)

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.

Calls C++ function: void QUrl::clear().

C++ documentation:

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.

See also isEmpty().

source

pub unsafe fn copy_from_q_url( &self, copy: impl CastInto<Ref<QUrl>> ) -> Ref<QUrl>

Assigns the specified url to this object.

Calls C++ function: QUrl& QUrl::operator=(const QUrl& copy).

C++ documentation:

Assigns the specified url to this object.

source

pub unsafe fn copy_from_q_string( &self, url: impl CastInto<Ref<QString>> ) -> Ref<QUrl>

Assigns the specified url to this object.

Calls C++ function: QUrl& QUrl::operator=(const QString& url).

C++ documentation:

Assigns the specified url to this object.

source

pub unsafe fn detach(&self)

Calls C++ function: void QUrl::detach().

source

pub unsafe fn error_string(&self) -> CppBox<QString>

Returns an error message if the last operation that modified this QUrl object ran into a parsing error. If no error was detected, this function returns an empty string and isValid() returns true.

Calls C++ function: QString QUrl::errorString() const.

C++ documentation:

Returns an error message if the last operation that modified this QUrl object ran into a parsing error. If no error was detected, this function returns an empty string and isValid() returns true.

The error message returned by this function is technical in nature and may not be understood by end users. It is mostly useful to developers trying to understand why QUrl will not accept some input.

This function was introduced in Qt 4.2.

See also QUrl::ParsingMode.

source

pub unsafe fn file_name_1a( &self, options: QFlags<ComponentFormattingOption> ) -> CppBox<QString>

Returns the name of the file, excluding the directory path.

Calls C++ function: QString QUrl::fileName(QFlags<QUrl::ComponentFormattingOption> options = …) const.

C++ documentation:

Returns the name of the file, excluding the directory path.

Note that, if this QUrl object is given a path ending in a slash, the name of the file is considered empty.

If the path doesn't contain any slash, it is fully returned as the fileName.

Example:

QUrl url(“http://qt-project.org/support/file.html”); // url.adjusted(RemoveFilename) == “http://qt-project.org/support/” // url.fileName() == “file.html”

The options argument controls how to format the file name component. All values produce an unambiguous result. With QUrl::FullyDecoded, all percent-encoded sequences are decoded; otherwise, the returned value may contain some percent-encoded sequences for some control sequences not representable in decoded form in QString.

This function was introduced in Qt 5.2.

See also path().

source

pub unsafe fn file_name_0a(&self) -> CppBox<QString>

Returns the name of the file, excluding the directory path.

Calls C++ function: QString QUrl::fileName() const.

C++ documentation:

Returns the name of the file, excluding the directory path.

Note that, if this QUrl object is given a path ending in a slash, the name of the file is considered empty.

If the path doesn't contain any slash, it is fully returned as the fileName.

Example:

QUrl url(“http://qt-project.org/support/file.html”); // url.adjusted(RemoveFilename) == “http://qt-project.org/support/” // url.fileName() == “file.html”

The options argument controls how to format the file name component. All values produce an unambiguous result. With QUrl::FullyDecoded, all percent-encoded sequences are decoded; otherwise, the returned value may contain some percent-encoded sequences for some control sequences not representable in decoded form in QString.

This function was introduced in Qt 5.2.

See also path().

source

pub unsafe fn fragment_1a( &self, options: QFlags<ComponentFormattingOption> ) -> CppBox<QString>

Returns the fragment of the URL. To determine if the parsed URL contained a fragment, use hasFragment().

Calls C++ function: QString QUrl::fragment(QFlags<QUrl::ComponentFormattingOption> options = …) const.

C++ documentation:

Returns the fragment of the URL. To determine if the parsed URL contained a fragment, use hasFragment().

The options argument controls how to format the fragment component. All values produce an unambiguous result. With QUrl::FullyDecoded, all percent-encoded sequences are decoded; otherwise, the returned value may contain some percent-encoded sequences for some control sequences not representable in decoded form in QString.

Note that QUrl::FullyDecoded may cause data loss if those non-representable sequences are present. It is recommended to use that value when the result will be used in a non-URL context.

See also setFragment() and hasFragment().

source

pub unsafe fn fragment_0a(&self) -> CppBox<QString>

Returns the fragment of the URL. To determine if the parsed URL contained a fragment, use hasFragment().

Calls C++ function: QString QUrl::fragment() const.

C++ documentation:

Returns the fragment of the URL. To determine if the parsed URL contained a fragment, use hasFragment().

The options argument controls how to format the fragment component. All values produce an unambiguous result. With QUrl::FullyDecoded, all percent-encoded sequences are decoded; otherwise, the returned value may contain some percent-encoded sequences for some control sequences not representable in decoded form in QString.

Note that QUrl::FullyDecoded may cause data loss if those non-representable sequences are present. It is recommended to use that value when the result will be used in a non-URL context.

See also setFragment() and hasFragment().

source

pub unsafe fn from_ace(arg1: impl CastInto<Ref<QByteArray>>) -> CppBox<QString>

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.

Calls C++ function: static QString QUrl::fromAce(const QByteArray& arg1).

C++ documentation:

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.

source

pub unsafe fn from_encoded_2a( url: impl CastInto<Ref<QByteArray>>, mode: ParsingMode ) -> CppBox<QUrl>

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

Calls C++ function: static QUrl QUrl::fromEncoded(const QByteArray& url, QUrl::ParsingMode mode = …).

C++ documentation:

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

Parses the URL using parsingMode. See setUrl() for more information on this parameter. QUrl::DecodedMode is not permitted in this context.

See also toEncoded() and setUrl().

source

pub unsafe fn from_encoded_1a( url: impl CastInto<Ref<QByteArray>> ) -> CppBox<QUrl>

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

Calls C++ function: static QUrl QUrl::fromEncoded(const QByteArray& url).

C++ documentation:

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

Parses the URL using parsingMode. See setUrl() for more information on this parameter. QUrl::DecodedMode is not permitted in this context.

See also toEncoded() and setUrl().

source

pub unsafe fn from_local_file( localfile: impl CastInto<Ref<QString>> ) -> CppBox<QUrl>

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.

Calls C++ function: static QUrl QUrl::fromLocalFile(const QString& localfile).

C++ documentation:

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

An empty localFile leads to an empty URL (since Qt 5.4).

qDebug() << QUrl::fromLocalFile(“file.txt”); // QUrl(“file:file.txt”) qDebug() << QUrl::fromLocalFile(“/home/user/file.txt”); // QUrl(“file:///home/user/file.txt”) qDebug() << QUrl::fromLocalFile(“file:file.txt”); // doesn’t make sense; expects path, not url with scheme

In the first line in snippet above, a file URL is constructed from a local, relative path. A file URL with a relative path only makes sense if there is a base URL to resolve it against. For example:

QUrl url = QUrl::fromLocalFile(“file.txt”); QUrl baseUrl = QUrl(“file:/home/user/”); // wrong: prints QUrl(“file:file.txt”), as url already has a scheme qDebug() << baseUrl.resolved(url);

To resolve such a URL, it's necessary to remove the scheme beforehand:

// correct: prints QUrl(“file:///home/user/file.txt”) url.setScheme(QString()); qDebug() << baseUrl.resolved(url);

For this reason, it is better to use a relative URL (that is, no scheme) for relative file paths:

QUrl url = QUrl(“file.txt”); QUrl baseUrl = QUrl(“file:/home/user/”); // prints QUrl(“file:///home/user/file.txt”) qDebug() << baseUrl.resolved(url);

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

source

pub unsafe fn from_percent_encoding( arg1: impl CastInto<Ref<QByteArray>> ) -> CppBox<QString>

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

Calls C++ function: static QString QUrl::fromPercentEncoding(const QByteArray& arg1).

C++ documentation:

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

Note: Given invalid input (such as a string containing the sequence "%G5", which is not a valid hexadecimal number) the output will be invalid as well. As an example: the sequence "%G5" could be decoded to 'W'.

source

pub unsafe fn from_string_list_2a( uris: impl CastInto<Ref<QStringList>>, mode: ParsingMode ) -> CppBox<QListOfQUrl>

Converts a list of strings representing urls into a list of urls, using QUrl(str, mode). Note that this means all strings must be urls, not for instance local paths.

Calls C++ function: static QList<QUrl> QUrl::fromStringList(const QStringList& uris, QUrl::ParsingMode mode = …).

C++ documentation:

Converts a list of strings representing urls into a list of urls, using QUrl(str, mode). Note that this means all strings must be urls, not for instance local paths.

This function was introduced in Qt 5.1.

source

pub unsafe fn from_string_list_1a( uris: impl CastInto<Ref<QStringList>> ) -> CppBox<QListOfQUrl>

Converts a list of strings representing urls into a list of urls, using QUrl(str, mode). Note that this means all strings must be urls, not for instance local paths.

Calls C++ function: static QList<QUrl> QUrl::fromStringList(const QStringList& uris).

C++ documentation:

Converts a list of strings representing urls into a list of urls, using QUrl(str, mode). Note that this means all strings must be urls, not for instance local paths.

This function was introduced in Qt 5.1.

source

pub unsafe fn from_user_input_1a( user_input: impl CastInto<Ref<QString>> ) -> CppBox<QUrl>

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.

Calls C++ function: static QUrl QUrl::fromUserInput(const QString& userInput).

C++ documentation:

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-project.org becomes http://qt-project.org
  • ftp.qt-project.org becomes ftp://ftp.qt-project.org
  • hostname becomes http://hostname
  • /home/user/test.html becomes file:///home/user/test.html

This function was introduced in Qt 4.6.

source

pub unsafe fn from_user_input_3a( user_input: impl CastInto<Ref<QString>>, working_directory: impl CastInto<Ref<QString>>, options: QFlags<UserInputResolutionOption> ) -> CppBox<QUrl>

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.

Calls C++ function: static QUrl QUrl::fromUserInput(const QString& userInput, const QString& workingDirectory, QFlags<QUrl::UserInputResolutionOption> options = …).

C++ documentation:

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.

This overload takes a workingDirectory path, in order to be able to handle relative paths. This is especially useful when handling command line arguments. If workingDirectory is empty, no handling of relative paths will be done, so this method will behave like its one argument overload.

By default, an input string that looks like a relative path will only be treated as such if the file actually exists in the given working directory.

If the application can handle files that don't exist yet, it should pass the flag AssumeLocalFile in options.

This function was introduced in Qt 5.4.

source

pub unsafe fn from_user_input_2a( user_input: impl CastInto<Ref<QString>>, working_directory: impl CastInto<Ref<QString>> ) -> CppBox<QUrl>

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.

Calls C++ function: static QUrl QUrl::fromUserInput(const QString& userInput, const QString& workingDirectory).

C++ documentation:

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.

This overload takes a workingDirectory path, in order to be able to handle relative paths. This is especially useful when handling command line arguments. If workingDirectory is empty, no handling of relative paths will be done, so this method will behave like its one argument overload.

By default, an input string that looks like a relative path will only be treated as such if the file actually exists in the given working directory.

If the application can handle files that don't exist yet, it should pass the flag AssumeLocalFile in options.

This function was introduced in Qt 5.4.

source

pub unsafe fn has_fragment(&self) -> bool

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

Calls C++ function: bool QUrl::hasFragment() const.

C++ documentation:

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

source

pub unsafe fn has_query(&self) -> bool

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

Calls C++ function: bool QUrl::hasQuery() const.

C++ documentation:

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 setQuery(), query(), and hasFragment().

source

pub unsafe fn host_1a( &self, arg1: QFlags<ComponentFormattingOption> ) -> CppBox<QString>

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

Calls C++ function: QString QUrl::host(QFlags<QUrl::ComponentFormattingOption> arg1 = …) const.

C++ documentation:

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

The options argument controls how the hostname will be formatted. The QUrl::EncodeUnicode option will cause this function to return the hostname in the ASCII-Compatible Encoding (ACE) form, which is suitable for use in channels that are not 8-bit clean or that require the legacy hostname (such as DNS requests or in HTTP request headers). If that flag is not present, this function returns the International Domain Name (IDN) in Unicode form, according to the list of permissible top-level domains (see idnWhitelist()).

All other flags are ignored. Host names cannot contain control or percent characters, so the returned value can be considered fully decoded.

See also setHost(), idnWhitelist(), setIdnWhitelist(), and authority().

source

pub unsafe fn host_0a(&self) -> CppBox<QString>

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

Calls C++ function: QString QUrl::host() const.

C++ documentation:

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

The options argument controls how the hostname will be formatted. The QUrl::EncodeUnicode option will cause this function to return the hostname in the ASCII-Compatible Encoding (ACE) form, which is suitable for use in channels that are not 8-bit clean or that require the legacy hostname (such as DNS requests or in HTTP request headers). If that flag is not present, this function returns the International Domain Name (IDN) in Unicode form, according to the list of permissible top-level domains (see idnWhitelist()).

All other flags are ignored. Host names cannot contain control or percent characters, so the returned value can be considered fully decoded.

See also setHost(), idnWhitelist(), setIdnWhitelist(), and authority().

source

pub unsafe fn idn_whitelist() -> CppBox<QStringList>

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

Calls C++ function: static QStringList QUrl::idnWhitelist().

C++ documentation:

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.

See also setIdnWhitelist().

source

pub unsafe fn is_detached(&self) -> bool

Calls C++ function: bool QUrl::isDetached() const.

source

pub unsafe fn is_empty(&self) -> bool

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

Calls C++ function: bool QUrl::isEmpty() const.

C++ documentation:

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

See also clear().

source

pub unsafe fn is_local_file(&self) -> bool

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

Calls C++ function: bool QUrl::isLocalFile() const.

C++ documentation:

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

source

pub unsafe fn is_parent_of(&self, url: impl CastInto<Ref<QUrl>>) -> bool

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.

Calls C++ function: bool QUrl::isParentOf(const QUrl& url) const.

C++ documentation:

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.

source

pub unsafe fn is_relative(&self) -> bool

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

Calls C++ function: bool QUrl::isRelative() const.

C++ documentation:

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

Relative references are defined in RFC 3986 section 4.2.

See also Relative URLs vs Relative Paths.

source

pub unsafe fn is_valid(&self) -> bool

Returns true if the URL is non-empty and valid; otherwise returns false.

Calls C++ function: bool QUrl::isValid() const.

C++ documentation:

Returns true if the URL is non-empty and 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(“Invalid URL: %s”, qUtf8Printable(url.toString())); return false; }

return true; }

source

pub unsafe fn matches( &self, url: impl CastInto<Ref<QUrl>>, options: impl CastInto<Ref<QUrlTwoFlagsOfUrlFormattingOptionComponentFormattingOption>> ) -> bool

Returns true if this URL and the given url are equal after applying options to both; otherwise returns false.

Calls C++ function: bool QUrl::matches(const QUrl& url, QUrlTwoFlags<QUrl::UrlFormattingOption, QUrl::ComponentFormattingOption> options) const.

C++ documentation:

Returns true if this URL and the given url are equal after applying options to both; otherwise returns false.

This is equivalent to calling adjusted(options) on both URLs and comparing the resulting urls, but faster.

This function was introduced in Qt 5.2.

source

pub unsafe fn new_0a() -> CppBox<QUrl>

Constructs an empty QUrl object.

Calls C++ function: [constructor] void QUrl::QUrl().

C++ documentation:

Constructs an empty QUrl object.

source

pub unsafe fn new_2a( url: impl CastInto<Ref<QString>>, mode: ParsingMode ) -> CppBox<QUrl>

Constructs a URL by parsing url. QUrl will automatically percent encode all characters that are not allowed in a URL and decode the percent-encoded sequences that represent an unreserved character (letters, digits, hyphens, undercores, dots and tildes). All other characters are left in their original forms.

Calls C++ function: [constructor] void QUrl::QUrl(const QString& url, QUrl::ParsingMode mode = …).

C++ documentation:

Constructs a URL by parsing url. QUrl will automatically percent encode all characters that are not allowed in a URL and decode the percent-encoded sequences that represent an unreserved character (letters, digits, hyphens, undercores, dots and tildes). All other characters are left in their original forms.

Parses the url using the parser mode parsingMode. In TolerantMode (the default), QUrl will correct certain mistakes, notably the presence of a percent character ('%') not followed by two hexadecimal digits, and it will accept any character in any position. In StrictMode, encoding mistakes will not be tolerated and QUrl will also check that certain forbidden characters are not present in unencoded form. If an error is detected in StrictMode, isValid() will return false. The parsing mode DecodedMode is not permitted in this context.

Example:

QUrl url(“http://www.example.com/List of holidays.xml”); // url.toEncoded() == “http://www.example.com/List%20of%20holidays.xml”

To construct a URL from an encoded string, you can also use fromEncoded():

QUrl url = QUrl::fromEncoded(“http://qt-project.org/List%20of%20holidays.xml”);

Both functions are equivalent and, in Qt 5, both functions accept encoded data. Usually, the choice of the QUrl constructor or setUrl() versus fromEncoded() will depend on the source data: the constructor and setUrl() take a QString, whereas fromEncoded takes a QByteArray.

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

source

pub unsafe fn new_1a(url: impl CastInto<Ref<QString>>) -> CppBox<QUrl>

Constructs a URL by parsing url. QUrl will automatically percent encode all characters that are not allowed in a URL and decode the percent-encoded sequences that represent an unreserved character (letters, digits, hyphens, undercores, dots and tildes). All other characters are left in their original forms.

Calls C++ function: [constructor] void QUrl::QUrl(const QString& url).

C++ documentation:

Constructs a URL by parsing url. QUrl will automatically percent encode all characters that are not allowed in a URL and decode the percent-encoded sequences that represent an unreserved character (letters, digits, hyphens, undercores, dots and tildes). All other characters are left in their original forms.

Parses the url using the parser mode parsingMode. In TolerantMode (the default), QUrl will correct certain mistakes, notably the presence of a percent character ('%') not followed by two hexadecimal digits, and it will accept any character in any position. In StrictMode, encoding mistakes will not be tolerated and QUrl will also check that certain forbidden characters are not present in unencoded form. If an error is detected in StrictMode, isValid() will return false. The parsing mode DecodedMode is not permitted in this context.

Example:

QUrl url(“http://www.example.com/List of holidays.xml”); // url.toEncoded() == “http://www.example.com/List%20of%20holidays.xml”

To construct a URL from an encoded string, you can also use fromEncoded():

QUrl url = QUrl::fromEncoded(“http://qt-project.org/List%20of%20holidays.xml”);

Both functions are equivalent and, in Qt 5, both functions accept encoded data. Usually, the choice of the QUrl constructor or setUrl() versus fromEncoded() will depend on the source data: the constructor and setUrl() take a QString, whereas fromEncoded takes a QByteArray.

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

source

pub unsafe fn new_copy(copy: impl CastInto<Ref<QUrl>>) -> CppBox<QUrl>

Constructs a copy of other.

Calls C++ function: [constructor] void QUrl::QUrl(const QUrl& copy).

C++ documentation:

Constructs a copy of other.

source

pub unsafe fn password_1a( &self, arg1: QFlags<ComponentFormattingOption> ) -> CppBox<QString>

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

Calls C++ function: QString QUrl::password(QFlags<QUrl::ComponentFormattingOption> arg1 = …) const.

C++ documentation:

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

The options argument controls how to format the user name component. All values produce an unambiguous result. With QUrl::FullyDecoded, all percent-encoded sequences are decoded; otherwise, the returned value may contain some percent-encoded sequences for some control sequences not representable in decoded form in QString.

Note that QUrl::FullyDecoded may cause data loss if those non-representable sequences are present. It is recommended to use that value when the result will be used in a non-URL context, such as setting in QAuthenticator or negotiating a login.

See also setPassword().

source

pub unsafe fn password_0a(&self) -> CppBox<QString>

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

Calls C++ function: QString QUrl::password() const.

C++ documentation:

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

The options argument controls how to format the user name component. All values produce an unambiguous result. With QUrl::FullyDecoded, all percent-encoded sequences are decoded; otherwise, the returned value may contain some percent-encoded sequences for some control sequences not representable in decoded form in QString.

Note that QUrl::FullyDecoded may cause data loss if those non-representable sequences are present. It is recommended to use that value when the result will be used in a non-URL context, such as setting in QAuthenticator or negotiating a login.

See also setPassword().

source

pub unsafe fn path_1a( &self, options: QFlags<ComponentFormattingOption> ) -> CppBox<QString>

Returns the path of the URL.

Calls C++ function: QString QUrl::path(QFlags<QUrl::ComponentFormattingOption> options = …) const.

C++ documentation:

Returns the path of the URL.


  qDebug() << QUrl("file:file.txt").path();                   // "file.txt"
  qDebug() << QUrl("/home/user/file.txt").path();             // "/home/user/file.txt"
  qDebug() << QUrl("http://www.example.com/test/123").path(); // "/test/123"

The options argument controls how to format the path component. All values produce an unambiguous result. With QUrl::FullyDecoded, all percent-encoded sequences are decoded; otherwise, the returned value may contain some percent-encoded sequences for some control sequences not representable in decoded form in QString.

Note that QUrl::FullyDecoded may cause data loss if those non-representable sequences are present. It is recommended to use that value when the result will be used in a non-URL context, such as sending to an FTP server.

An example of data loss is when you have non-Unicode percent-encoded sequences and use FullyDecoded (the default):

qDebug() << QUrl(“/foo%FFbar”).path();

In this example, there will be some level of data loss because the %FF cannot be converted.

Data loss can also occur when the path contains sub-delimiters (such as +):

qDebug() << QUrl(“/foo+bar%2B”).path(); // “/foo+bar+”

Other decoding examples:

const QUrl url(“/tmp/Mambo %235%3F.mp3”); qDebug() << url.path(QUrl::FullyDecoded); // “/tmp/Mambo #5?.mp3” qDebug() << url.path(QUrl::PrettyDecoded); // “/tmp/Mambo #5?.mp3” qDebug() << url.path(QUrl::FullyEncoded); // “/tmp/Mambo%20%235%3F.mp3”

See also setPath().

source

pub unsafe fn path_0a(&self) -> CppBox<QString>

Returns the path of the URL.

Calls C++ function: QString QUrl::path() const.

C++ documentation:

Returns the path of the URL.


  qDebug() << QUrl("file:file.txt").path();                   // "file.txt"
  qDebug() << QUrl("/home/user/file.txt").path();             // "/home/user/file.txt"
  qDebug() << QUrl("http://www.example.com/test/123").path(); // "/test/123"

The options argument controls how to format the path component. All values produce an unambiguous result. With QUrl::FullyDecoded, all percent-encoded sequences are decoded; otherwise, the returned value may contain some percent-encoded sequences for some control sequences not representable in decoded form in QString.

Note that QUrl::FullyDecoded may cause data loss if those non-representable sequences are present. It is recommended to use that value when the result will be used in a non-URL context, such as sending to an FTP server.

An example of data loss is when you have non-Unicode percent-encoded sequences and use FullyDecoded (the default):

qDebug() << QUrl(“/foo%FFbar”).path();

In this example, there will be some level of data loss because the %FF cannot be converted.

Data loss can also occur when the path contains sub-delimiters (such as +):

qDebug() << QUrl(“/foo+bar%2B”).path(); // “/foo+bar+”

Other decoding examples:

const QUrl url(“/tmp/Mambo %235%3F.mp3”); qDebug() << url.path(QUrl::FullyDecoded); // “/tmp/Mambo #5?.mp3” qDebug() << url.path(QUrl::PrettyDecoded); // “/tmp/Mambo #5?.mp3” qDebug() << url.path(QUrl::FullyEncoded); // “/tmp/Mambo%20%235%3F.mp3”

See also setPath().

source

pub unsafe fn port_1a(&self, default_port: c_int) -> c_int

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

Calls C++ function: int QUrl::port(int defaultPort = …) const.

C++ documentation:

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

Example:

QTcpSocket sock; sock.connectToHost(url.host(), url.port(80));

This function was introduced in Qt 4.1.

See also setPort().

source

pub unsafe fn port_0a(&self) -> c_int

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

Calls C++ function: int QUrl::port() const.

C++ documentation:

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

Example:

QTcpSocket sock; sock.connectToHost(url.host(), url.port(80));

This function was introduced in Qt 4.1.

See also setPort().

source

pub unsafe fn query_1a( &self, arg1: QFlags<ComponentFormattingOption> ) -> CppBox<QString>

Returns the query string of the URL if there's a query string, or an empty result if not. To determine if the parsed URL contained a query string, use hasQuery().

Calls C++ function: QString QUrl::query(QFlags<QUrl::ComponentFormattingOption> arg1 = …) const.

C++ documentation:

Returns the query string of the URL if there’s a query string, or an empty result if not. To determine if the parsed URL contained a query string, use hasQuery().

The options argument controls how to format the query component. All values produce an unambiguous result. With QUrl::FullyDecoded, all percent-encoded sequences are decoded; otherwise, the returned value may contain some percent-encoded sequences for some control sequences not representable in decoded form in QString.

Note that use of QUrl::FullyDecoded in queries is discouraged, as queries often contain data that is supposed to remain percent-encoded, including the use of the "%2B" sequence to represent a plus character ('+').

See also setQuery() and hasQuery().

source

pub unsafe fn query_0a(&self) -> CppBox<QString>

Returns the query string of the URL if there's a query string, or an empty result if not. To determine if the parsed URL contained a query string, use hasQuery().

Calls C++ function: QString QUrl::query() const.

C++ documentation:

Returns the query string of the URL if there’s a query string, or an empty result if not. To determine if the parsed URL contained a query string, use hasQuery().

The options argument controls how to format the query component. All values produce an unambiguous result. With QUrl::FullyDecoded, all percent-encoded sequences are decoded; otherwise, the returned value may contain some percent-encoded sequences for some control sequences not representable in decoded form in QString.

Note that use of QUrl::FullyDecoded in queries is discouraged, as queries often contain data that is supposed to remain percent-encoded, including the use of the "%2B" sequence to represent a plus character ('+').

See also setQuery() and hasQuery().

source

pub unsafe fn resolved( &self, relative: impl CastInto<Ref<QUrl>> ) -> CppBox<QUrl>

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.

Calls C++ function: QUrl QUrl::resolved(const QUrl& relative) const.

C++ documentation:

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.digia.com/Support/”); QUrl relativeUrl(“../Product/Library/”); qDebug(baseUrl.resolved(relativeUrl).toString()); // prints “http://qt.digia.com/Product/Library/”

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

source

pub unsafe fn scheme(&self) -> CppBox<QString>

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

Calls C++ function: QString QUrl::scheme() const.

C++ documentation:

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

The scheme can only contain US-ASCII letters or digits, which means it cannot contain any character that would otherwise require encoding. Additionally, schemes are always returned in lowercase form.

See also setScheme() and isRelative().

source

pub unsafe fn set_authority_2a( &self, authority: impl CastInto<Ref<QString>>, mode: ParsingMode )

Sets the authority of the URL to authority.

Calls C++ function: void QUrl::setAuthority(const QString& authority, QUrl::ParsingMode mode = …).

C++ documentation:

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:

The authority data is interpreted according to mode: in StrictMode, any '%' characters must be followed by exactly two hexadecimal characters and some characters (including space) are not allowed in undecoded form. In TolerantMode (the default), all characters are accepted in undecoded form and the tolerant parser will correct stray '%' not followed by two hex characters.

This function does not allow mode to be QUrl::DecodedMode. To set fully decoded data, call setUserName(), setPassword(), setHost() and setPort() individually.

See also authority(), setUserInfo(), setHost(), and setPort().

source

pub unsafe fn set_authority_1a(&self, authority: impl CastInto<Ref<QString>>)

Sets the authority of the URL to authority.

Calls C++ function: void QUrl::setAuthority(const QString& authority).

C++ documentation:

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:

The authority data is interpreted according to mode: in StrictMode, any '%' characters must be followed by exactly two hexadecimal characters and some characters (including space) are not allowed in undecoded form. In TolerantMode (the default), all characters are accepted in undecoded form and the tolerant parser will correct stray '%' not followed by two hex characters.

This function does not allow mode to be QUrl::DecodedMode. To set fully decoded data, call setUserName(), setPassword(), setHost() and setPort() individually.

See also authority(), setUserInfo(), setHost(), and setPort().

source

pub unsafe fn set_fragment_2a( &self, fragment: impl CastInto<Ref<QString>>, mode: ParsingMode )

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:

Calls C++ function: void QUrl::setFragment(const QString& fragment, QUrl::ParsingMode mode = …).

C++ documentation:

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

The fragment data is interpreted according to mode: in StrictMode, any '%' characters must be followed by exactly two hexadecimal characters and some characters (including space) are not allowed in undecoded form. In TolerantMode, all characters are accepted in undecoded form and the tolerant parser will correct stray '%' not followed by two hex characters. In DecodedMode, '%' stand for themselves and encoded characters are not possible.

QUrl::DecodedMode should be used when setting the fragment from a data source which is not a URL or with a fragment obtained by calling fragment() with the QUrl::FullyDecoded formatting option.

See also fragment() and hasFragment().

source

pub unsafe fn set_fragment_1a(&self, fragment: impl CastInto<Ref<QString>>)

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:

Calls C++ function: void QUrl::setFragment(const QString& fragment).

C++ documentation:

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

The fragment data is interpreted according to mode: in StrictMode, any '%' characters must be followed by exactly two hexadecimal characters and some characters (including space) are not allowed in undecoded form. In TolerantMode, all characters are accepted in undecoded form and the tolerant parser will correct stray '%' not followed by two hex characters. In DecodedMode, '%' stand for themselves and encoded characters are not possible.

QUrl::DecodedMode should be used when setting the fragment from a data source which is not a URL or with a fragment obtained by calling fragment() with the QUrl::FullyDecoded formatting option.

See also fragment() and hasFragment().

source

pub unsafe fn set_host_2a( &self, host: impl CastInto<Ref<QString>>, mode: ParsingMode )

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

Calls C++ function: void QUrl::setHost(const QString& host, QUrl::ParsingMode mode = …).

C++ documentation:

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

The host data is interpreted according to mode: in StrictMode, any '%' characters must be followed by exactly two hexadecimal characters and some characters (including space) are not allowed in undecoded form. In TolerantMode, all characters are accepted in undecoded form and the tolerant parser will correct stray '%' not followed by two hex characters. In DecodedMode, '%' stand for themselves and encoded characters are not possible.

Note that, in all cases, the result of the parsing must be a valid hostname according to STD 3 rules, as modified by the Internationalized Resource Identifiers specification (RFC 3987). Invalid hostnames are not permitted and will cause isValid() to become false.

See also host() and setAuthority().

source

pub unsafe fn set_host_1a(&self, host: impl CastInto<Ref<QString>>)

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

Calls C++ function: void QUrl::setHost(const QString& host).

C++ documentation:

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

The host data is interpreted according to mode: in StrictMode, any '%' characters must be followed by exactly two hexadecimal characters and some characters (including space) are not allowed in undecoded form. In TolerantMode, all characters are accepted in undecoded form and the tolerant parser will correct stray '%' not followed by two hex characters. In DecodedMode, '%' stand for themselves and encoded characters are not possible.

Note that, in all cases, the result of the parsing must be a valid hostname according to STD 3 rules, as modified by the Internationalized Resource Identifiers specification (RFC 3987). Invalid hostnames are not permitted and will cause isValid() to become false.

See also host() and setAuthority().

source

pub unsafe fn set_idn_whitelist(arg1: impl CastInto<Ref<QStringList>>)

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

Calls C++ function: static void QUrl::setIdnWhitelist(const QStringList& arg1).

C++ documentation:

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 before you start any threads that might access idnWhitelist().

Qt comes with 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.

See also idnWhitelist().

source

pub unsafe fn set_password_2a( &self, password: impl CastInto<Ref<QString>>, mode: ParsingMode )

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

Calls C++ function: void QUrl::setPassword(const QString& password, QUrl::ParsingMode mode = …).

C++ documentation:

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

The password data is interpreted according to mode: in StrictMode, any '%' characters must be followed by exactly two hexadecimal characters and some characters (including space) are not allowed in undecoded form. In TolerantMode, all characters are accepted in undecoded form and the tolerant parser will correct stray '%' not followed by two hex characters. In DecodedMode, '%' stand for themselves and encoded characters are not possible.

QUrl::DecodedMode should be used when setting the password from a data source which is not a URL, such as a password dialog shown to the user or with a password obtained by calling password() with the QUrl::FullyDecoded formatting option.

See also password() and setUserInfo().

source

pub unsafe fn set_password_1a(&self, password: impl CastInto<Ref<QString>>)

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

Calls C++ function: void QUrl::setPassword(const QString& password).

C++ documentation:

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

The password data is interpreted according to mode: in StrictMode, any '%' characters must be followed by exactly two hexadecimal characters and some characters (including space) are not allowed in undecoded form. In TolerantMode, all characters are accepted in undecoded form and the tolerant parser will correct stray '%' not followed by two hex characters. In DecodedMode, '%' stand for themselves and encoded characters are not possible.

QUrl::DecodedMode should be used when setting the password from a data source which is not a URL, such as a password dialog shown to the user or with a password obtained by calling password() with the QUrl::FullyDecoded formatting option.

See also password() and setUserInfo().

source

pub unsafe fn set_path_2a( &self, path: impl CastInto<Ref<QString>>, mode: ParsingMode )

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.

Calls C++ function: void QUrl::setPath(const QString& path, QUrl::ParsingMode mode = …).

C++ documentation:

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:

The path data is interpreted according to mode: in StrictMode, any '%' characters must be followed by exactly two hexadecimal characters and some characters (including space) are not allowed in undecoded form. In TolerantMode (the default), all characters are accepted in undecoded form and the tolerant parser will correct stray '%' not followed by two hex characters. In DecodedMode, '%' stand for themselves and encoded characters are not possible.

QUrl::DecodedMode should be used when setting the path from a data source which is not a URL, such as a dialog shown to the user or with a path obtained by calling path() with the QUrl::FullyDecoded formatting option.

See also path().

source

pub unsafe fn set_path_1a(&self, path: impl CastInto<Ref<QString>>)

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.

Calls C++ function: void QUrl::setPath(const QString& path).

C++ documentation:

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:

The path data is interpreted according to mode: in StrictMode, any '%' characters must be followed by exactly two hexadecimal characters and some characters (including space) are not allowed in undecoded form. In TolerantMode (the default), all characters are accepted in undecoded form and the tolerant parser will correct stray '%' not followed by two hex characters. In DecodedMode, '%' stand for themselves and encoded characters are not possible.

QUrl::DecodedMode should be used when setting the path from a data source which is not a URL, such as a dialog shown to the user or with a path obtained by calling path() with the QUrl::FullyDecoded formatting option.

See also path().

source

pub unsafe fn set_port(&self, port: c_int)

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

Calls C++ function: void QUrl::setPort(int port).

C++ documentation:

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

source

pub unsafe fn set_query_q_string_parsing_mode( &self, query: impl CastInto<Ref<QString>>, mode: ParsingMode )

Sets the query string of the URL to query.

Calls C++ function: void QUrl::setQuery(const QString& query, QUrl::ParsingMode mode = …).

C++ documentation:

Sets the query string of the URL to query.

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 QString() to query (a null QString) unsets the query completely. However, passing a value of QString("") will set the query to an empty value, as if the original URL had a lone "?".

The query data is interpreted according to mode: in StrictMode, any '%' characters must be followed by exactly two hexadecimal characters and some characters (including space) are not allowed in undecoded form. In TolerantMode, all characters are accepted in undecoded form and the tolerant parser will correct stray '%' not followed by two hex characters. In DecodedMode, '%' stand for themselves and encoded characters are not possible.

Query strings often contain percent-encoded sequences, so use of DecodedMode is discouraged. One special sequence to be aware of is that of the plus character ('+'). QUrl does not convert spaces to plus characters, even though HTML forms posted by web browsers do. In order to represent an actual plus character in a query, the sequence "%2B" is usually used. This function will leave "%2B" sequences untouched in TolerantMode or StrictMode.

See also query() and hasQuery().

source

pub unsafe fn set_query_q_url_query(&self, query: impl CastInto<Ref<QUrlQuery>>)

This is an overloaded function.

Calls C++ function: void QUrl::setQuery(const QUrlQuery& query).

C++ documentation:

This is an overloaded function.

Sets the query string of the URL to query.

This function reconstructs the query string from the QUrlQuery object and sets on this QUrl object. This function does not have parsing parameters because the QUrlQuery contains data that is already parsed.

This function was introduced in Qt 5.0.

See also query() and hasQuery().

source

pub unsafe fn set_query_q_string(&self, query: impl CastInto<Ref<QString>>)

Sets the query string of the URL to query.

Calls C++ function: void QUrl::setQuery(const QString& query).

C++ documentation:

Sets the query string of the URL to query.

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 QString() to query (a null QString) unsets the query completely. However, passing a value of QString("") will set the query to an empty value, as if the original URL had a lone "?".

The query data is interpreted according to mode: in StrictMode, any '%' characters must be followed by exactly two hexadecimal characters and some characters (including space) are not allowed in undecoded form. In TolerantMode, all characters are accepted in undecoded form and the tolerant parser will correct stray '%' not followed by two hex characters. In DecodedMode, '%' stand for themselves and encoded characters are not possible.

Query strings often contain percent-encoded sequences, so use of DecodedMode is discouraged. One special sequence to be aware of is that of the plus character ('+'). QUrl does not convert spaces to plus characters, even though HTML forms posted by web browsers do. In order to represent an actual plus character in a query, the sequence "%2B" is usually used. This function will leave "%2B" sequences untouched in TolerantMode or StrictMode.

See also query() and hasQuery().

source

pub unsafe fn set_scheme(&self, scheme: impl CastInto<Ref<QString>>)

Sets the scheme of the URL to scheme. As a scheme can only contain ASCII characters, no conversion or decoding is done on the input. It must also start with an ASCII letter.

Calls C++ function: void QUrl::setScheme(const QString& scheme).

C++ documentation:

Sets the scheme of the URL to scheme. As a scheme can only contain ASCII characters, no conversion or decoding is done on the input. It must also start with an ASCII letter.

The scheme describes the type (or protocol) of the URL. It's represented by one or more ASCII characters at the start the URL.

A scheme is strictly RFC 3986-compliant: scheme = ALPHA *( ALPHA / DIGIT / "+" / "-" / "." )

The following example shows a URL where the scheme is "ftp":

To set the scheme, the following call is used:

QUrl url; url.setScheme(“ftp”);

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

See also scheme() and isRelative().

source

pub unsafe fn set_url_2a( &self, url: impl CastInto<Ref<QString>>, mode: ParsingMode )

Parses url and sets this object to that value. QUrl will automatically percent encode all characters that are not allowed in a URL and decode the percent-encoded sequences that represent an unreserved character (letters, digits, hyphens, undercores, dots and tildes). All other characters are left in their original forms.

Calls C++ function: void QUrl::setUrl(const QString& url, QUrl::ParsingMode mode = …).

C++ documentation:

Parses url and sets this object to that value. QUrl will automatically percent encode all characters that are not allowed in a URL and decode the percent-encoded sequences that represent an unreserved character (letters, digits, hyphens, undercores, dots and tildes). All other characters are left in their original forms.

Parses the url using the parser mode parsingMode. In TolerantMode (the default), QUrl will correct certain mistakes, notably the presence of a percent character ('%') not followed by two hexadecimal digits, and it will accept any character in any position. In StrictMode, encoding mistakes will not be tolerated and QUrl will also check that certain forbidden characters are not present in unencoded form. If an error is detected in StrictMode, isValid() will return false. The parsing mode DecodedMode is not permitted in this context and will produce a run-time warning.

See also url() and toString().

source

pub unsafe fn set_url_1a(&self, url: impl CastInto<Ref<QString>>)

Parses url and sets this object to that value. QUrl will automatically percent encode all characters that are not allowed in a URL and decode the percent-encoded sequences that represent an unreserved character (letters, digits, hyphens, undercores, dots and tildes). All other characters are left in their original forms.

Calls C++ function: void QUrl::setUrl(const QString& url).

C++ documentation:

Parses url and sets this object to that value. QUrl will automatically percent encode all characters that are not allowed in a URL and decode the percent-encoded sequences that represent an unreserved character (letters, digits, hyphens, undercores, dots and tildes). All other characters are left in their original forms.

Parses the url using the parser mode parsingMode. In TolerantMode (the default), QUrl will correct certain mistakes, notably the presence of a percent character ('%') not followed by two hexadecimal digits, and it will accept any character in any position. In StrictMode, encoding mistakes will not be tolerated and QUrl will also check that certain forbidden characters are not present in unencoded form. If an error is detected in StrictMode, isValid() will return false. The parsing mode DecodedMode is not permitted in this context and will produce a run-time warning.

See also url() and toString().

source

pub unsafe fn set_user_info_2a( &self, user_info: impl CastInto<Ref<QString>>, mode: ParsingMode )

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

Calls C++ function: void QUrl::setUserInfo(const QString& userInfo, QUrl::ParsingMode mode = …).

C++ documentation:

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:

The userInfo data is interpreted according to mode: in StrictMode, any '%' characters must be followed by exactly two hexadecimal characters and some characters (including space) are not allowed in undecoded form. In TolerantMode (the default), all characters are accepted in undecoded form and the tolerant parser will correct stray '%' not followed by two hex characters.

This function does not allow mode to be QUrl::DecodedMode. To set fully decoded data, call setUserName() and setPassword() individually.

See also userInfo(), setUserName(), setPassword(), and setAuthority().

source

pub unsafe fn set_user_info_1a(&self, user_info: impl CastInto<Ref<QString>>)

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

Calls C++ function: void QUrl::setUserInfo(const QString& userInfo).

C++ documentation:

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:

The userInfo data is interpreted according to mode: in StrictMode, any '%' characters must be followed by exactly two hexadecimal characters and some characters (including space) are not allowed in undecoded form. In TolerantMode (the default), all characters are accepted in undecoded form and the tolerant parser will correct stray '%' not followed by two hex characters.

This function does not allow mode to be QUrl::DecodedMode. To set fully decoded data, call setUserName() and setPassword() individually.

See also userInfo(), setUserName(), setPassword(), and setAuthority().

source

pub unsafe fn set_user_name_2a( &self, user_name: impl CastInto<Ref<QString>>, mode: ParsingMode )

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

Calls C++ function: void QUrl::setUserName(const QString& userName, QUrl::ParsingMode mode = …).

C++ documentation:

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

The userName data is interpreted according to mode: in StrictMode, any '%' characters must be followed by exactly two hexadecimal characters and some characters (including space) are not allowed in undecoded form. In TolerantMode (the default), all characters are accepted in undecoded form and the tolerant parser will correct stray '%' not followed by two hex characters. In DecodedMode, '%' stand for themselves and encoded characters are not possible.

QUrl::DecodedMode should be used when setting the user name from a data source which is not a URL, such as a password dialog shown to the user or with a user name obtained by calling userName() with the QUrl::FullyDecoded formatting option.

See also userName() and setUserInfo().

source

pub unsafe fn set_user_name_1a(&self, user_name: impl CastInto<Ref<QString>>)

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

Calls C++ function: void QUrl::setUserName(const QString& userName).

C++ documentation:

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

The userName data is interpreted according to mode: in StrictMode, any '%' characters must be followed by exactly two hexadecimal characters and some characters (including space) are not allowed in undecoded form. In TolerantMode (the default), all characters are accepted in undecoded form and the tolerant parser will correct stray '%' not followed by two hex characters. In DecodedMode, '%' stand for themselves and encoded characters are not possible.

QUrl::DecodedMode should be used when setting the user name from a data source which is not a URL, such as a password dialog shown to the user or with a user name obtained by calling userName() with the QUrl::FullyDecoded formatting option.

See also userName() and setUserInfo().

source

pub unsafe fn swap(&self, other: impl CastInto<Ref<QUrl>>)

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

Calls C++ function: void QUrl::swap(QUrl& other).

C++ documentation:

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

This function was introduced in Qt 4.8.

source

pub unsafe fn to_ace(arg1: impl CastInto<Ref<QString>>) -> CppBox<QByteArray>

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

Calls C++ function: static QByteArray QUrl::toAce(const QString& arg1).

C++ documentation:

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 returns an empty QByteArray 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.

source

pub unsafe fn to_display_string_1a( &self, options: impl CastInto<Ref<QUrlTwoFlagsOfUrlFormattingOptionComponentFormattingOption>> ) -> CppBox<QString>

Returns a human-displayable string representation of the URL. The output can be customized by passing flags with options. The option RemovePassword is always enabled, since passwords should never be shown back to users.

Calls C++ function: QString QUrl::toDisplayString(QUrlTwoFlags<QUrl::UrlFormattingOption, QUrl::ComponentFormattingOption> options = …) const.

C++ documentation:

Returns a human-displayable string representation of the URL. The output can be customized by passing flags with options. The option RemovePassword is always enabled, since passwords should never be shown back to users.

With the default options, the resulting QString can be passed back to a QUrl later on, but any password that was present initially will be lost.

This function was introduced in Qt 5.0.

See also FormattingOptions, toEncoded(), and toString().

source

pub unsafe fn to_display_string_0a(&self) -> CppBox<QString>

Returns a human-displayable string representation of the URL. The output can be customized by passing flags with options. The option RemovePassword is always enabled, since passwords should never be shown back to users.

Calls C++ function: QString QUrl::toDisplayString() const.

C++ documentation:

Returns a human-displayable string representation of the URL. The output can be customized by passing flags with options. The option RemovePassword is always enabled, since passwords should never be shown back to users.

With the default options, the resulting QString can be passed back to a QUrl later on, but any password that was present initially will be lost.

This function was introduced in Qt 5.0.

See also FormattingOptions, toEncoded(), and toString().

source

pub unsafe fn to_encoded_1a( &self, options: impl CastInto<Ref<QUrlTwoFlagsOfUrlFormattingOptionComponentFormattingOption>> ) -> CppBox<QByteArray>

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.

Calls C++ function: QByteArray QUrl::toEncoded(QUrlTwoFlags<QUrl::UrlFormattingOption, QUrl::ComponentFormattingOption> options = …) const.

C++ documentation:

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.

source

pub unsafe fn to_encoded_0a(&self) -> CppBox<QByteArray>

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.

Calls C++ function: QByteArray QUrl::toEncoded() const.

C++ documentation:

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.

source

pub unsafe fn to_local_file(&self) -> CppBox<QString>

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.

Calls C++ function: QString QUrl::toLocalFile() const.

C++ documentation:

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

qDebug() << QUrl(“file:file.txt”).toLocalFile(); // “file:file.txt” qDebug() << QUrl(“file:/home/user/file.txt”).toLocalFile(); // “file:///home/user/file.txt” qDebug() << QUrl(“file.txt”).toLocalFile(); // “”; wasn’t a local file as it had no scheme

Note: if the path component of this URL contains a non-UTF-8 binary sequence (such as %80), the behaviour of this function is undefined.

See also fromLocalFile() and isLocalFile().

source

pub unsafe fn to_percent_encoding_3a( arg1: impl CastInto<Ref<QString>>, exclude: impl CastInto<Ref<QByteArray>>, include: impl CastInto<Ref<QByteArray>> ) -> CppBox<QByteArray>

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.

Calls C++ function: static QByteArray QUrl::toPercentEncoding(const QString& arg1, const QByteArray& exclude = …, const QByteArray& include = …).

C++ documentation:

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}”

source

pub unsafe fn to_percent_encoding_2a( arg1: impl CastInto<Ref<QString>>, exclude: impl CastInto<Ref<QByteArray>> ) -> CppBox<QByteArray>

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.

Calls C++ function: static QByteArray QUrl::toPercentEncoding(const QString& arg1, const QByteArray& exclude = …).

C++ documentation:

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}”

source

pub unsafe fn to_percent_encoding_1a( arg1: impl CastInto<Ref<QString>> ) -> CppBox<QByteArray>

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.

Calls C++ function: static QByteArray QUrl::toPercentEncoding(const QString& arg1).

C++ documentation:

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}”

source

pub unsafe fn to_string_1a( &self, options: impl CastInto<Ref<QUrlTwoFlagsOfUrlFormattingOptionComponentFormattingOption>> ) -> CppBox<QString>

Returns a string representation of the URL. The output can be customized by passing flags with options. The option QUrl::FullyDecoded is not permitted in this function since it would generate ambiguous data.

Calls C++ function: QString QUrl::toString(QUrlTwoFlags<QUrl::UrlFormattingOption, QUrl::ComponentFormattingOption> options = …) const.

C++ documentation:

Returns a string representation of the URL. The output can be customized by passing flags with options. The option QUrl::FullyDecoded is not permitted in this function since it would generate ambiguous data.

The default formatting option is PrettyDecoded.

See also FormattingOptions, url(), and setUrl().

source

pub unsafe fn to_string_0a(&self) -> CppBox<QString>

Returns a string representation of the URL. The output can be customized by passing flags with options. The option QUrl::FullyDecoded is not permitted in this function since it would generate ambiguous data.

Calls C++ function: QString QUrl::toString() const.

C++ documentation:

Returns a string representation of the URL. The output can be customized by passing flags with options. The option QUrl::FullyDecoded is not permitted in this function since it would generate ambiguous data.

The default formatting option is PrettyDecoded.

See also FormattingOptions, url(), and setUrl().

source

pub unsafe fn to_string_list_2a( uris: impl CastInto<Ref<QListOfQUrl>>, options: impl CastInto<Ref<QUrlTwoFlagsOfUrlFormattingOptionComponentFormattingOption>> ) -> CppBox<QStringList>

Converts a list of urls into a list of QString objects, using toString(options).

Calls C++ function: static QStringList QUrl::toStringList(const QList<QUrl>& uris, QUrlTwoFlags<QUrl::UrlFormattingOption, QUrl::ComponentFormattingOption> options = …).

C++ documentation:

Converts a list of urls into a list of QString objects, using toString(options).

This function was introduced in Qt 5.1.

source

pub unsafe fn to_string_list_1a( uris: impl CastInto<Ref<QListOfQUrl>> ) -> CppBox<QStringList>

Converts a list of urls into a list of QString objects, using toString(options).

Calls C++ function: static QStringList QUrl::toStringList(const QList<QUrl>& uris).

C++ documentation:

Converts a list of urls into a list of QString objects, using toString(options).

This function was introduced in Qt 5.1.

source

pub unsafe fn top_level_domain_1a( &self, options: QFlags<ComponentFormattingOption> ) -> CppBox<QString>

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.

Calls C++ function: QString QUrl::topLevelDomain(QFlags<QUrl::ComponentFormattingOption> options = …) const.

C++ documentation:

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.

Note that this function considers a TLD to be any domain that allows users to register subdomains under, including many home, dynamic DNS websites and blogging providers. This is useful for determining whether two websites belong to the same infrastructure and communication should be allowed, such as browser cookies: two domains should be considered part of the same website if they share at least one label in addition to the value returned by this function.

  • foo.co.uk and foo.com do not share a top-level domain
  • foo.co.uk and bar.co.uk share the .co.uk domain, but the next label is different
  • www.foo.co.uk and ftp.foo.co.uk share the same top-level domain and one more label, so they are considered part of the same site

If options includes EncodeUnicode, the returned string will be in ASCII Compatible Encoding.

This function was introduced in Qt 4.8.

source

pub unsafe fn top_level_domain_0a(&self) -> CppBox<QString>

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.

Calls C++ function: QString QUrl::topLevelDomain() const.

C++ documentation:

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.

Note that this function considers a TLD to be any domain that allows users to register subdomains under, including many home, dynamic DNS websites and blogging providers. This is useful for determining whether two websites belong to the same infrastructure and communication should be allowed, such as browser cookies: two domains should be considered part of the same website if they share at least one label in addition to the value returned by this function.

  • foo.co.uk and foo.com do not share a top-level domain
  • foo.co.uk and bar.co.uk share the .co.uk domain, but the next label is different
  • www.foo.co.uk and ftp.foo.co.uk share the same top-level domain and one more label, so they are considered part of the same site

If options includes EncodeUnicode, the returned string will be in ASCII Compatible Encoding.

This function was introduced in Qt 4.8.

source

pub unsafe fn url_1a( &self, options: impl CastInto<Ref<QUrlTwoFlagsOfUrlFormattingOptionComponentFormattingOption>> ) -> CppBox<QString>

Returns a string representation of the URL. The output can be customized by passing flags with options. The option QUrl::FullyDecoded is not permitted in this function since it would generate ambiguous data.

Calls C++ function: QString QUrl::url(QUrlTwoFlags<QUrl::UrlFormattingOption, QUrl::ComponentFormattingOption> options = …) const.

C++ documentation:

Returns a string representation of the URL. The output can be customized by passing flags with options. The option QUrl::FullyDecoded is not permitted in this function since it would generate ambiguous data.

The resulting QString can be passed back to a QUrl later on.

Synonym for toString(options).

See also setUrl(), FormattingOptions, toEncoded(), and toString().

source

pub unsafe fn url_0a(&self) -> CppBox<QString>

Returns a string representation of the URL. The output can be customized by passing flags with options. The option QUrl::FullyDecoded is not permitted in this function since it would generate ambiguous data.

Calls C++ function: QString QUrl::url() const.

C++ documentation:

Returns a string representation of the URL. The output can be customized by passing flags with options. The option QUrl::FullyDecoded is not permitted in this function since it would generate ambiguous data.

The resulting QString can be passed back to a QUrl later on.

Synonym for toString(options).

See also setUrl(), FormattingOptions, toEncoded(), and toString().

source

pub unsafe fn user_info_1a( &self, options: QFlags<ComponentFormattingOption> ) -> CppBox<QString>

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

Calls C++ function: QString QUrl::userInfo(QFlags<QUrl::ComponentFormattingOption> options = …) const.

C++ documentation:

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

This function returns an unambiguous value, which may contain that characters still percent-encoded, plus some control sequences not representable in decoded form in QString.

The options argument controls how to format the user info component. The value of QUrl::FullyDecoded is not permitted in this function. If you need to obtain fully decoded data, call userName() and password() individually.

See also setUserInfo(), userName(), password(), and authority().

source

pub unsafe fn user_info_0a(&self) -> CppBox<QString>

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

Calls C++ function: QString QUrl::userInfo() const.

C++ documentation:

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

This function returns an unambiguous value, which may contain that characters still percent-encoded, plus some control sequences not representable in decoded form in QString.

The options argument controls how to format the user info component. The value of QUrl::FullyDecoded is not permitted in this function. If you need to obtain fully decoded data, call userName() and password() individually.

See also setUserInfo(), userName(), password(), and authority().

source

pub unsafe fn user_name_1a( &self, options: QFlags<ComponentFormattingOption> ) -> CppBox<QString>

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

Calls C++ function: QString QUrl::userName(QFlags<QUrl::ComponentFormattingOption> options = …) const.

C++ documentation:

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

The options argument controls how to format the user name component. All values produce an unambiguous result. With QUrl::FullyDecoded, all percent-encoded sequences are decoded; otherwise, the returned value may contain some percent-encoded sequences for some control sequences not representable in decoded form in QString.

Note that QUrl::FullyDecoded may cause data loss if those non-representable sequences are present. It is recommended to use that value when the result will be used in a non-URL context, such as setting in QAuthenticator or negotiating a login.

See also setUserName() and userInfo().

source

pub unsafe fn user_name_0a(&self) -> CppBox<QString>

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

Calls C++ function: QString QUrl::userName() const.

C++ documentation:

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

The options argument controls how to format the user name component. All values produce an unambiguous result. With QUrl::FullyDecoded, all percent-encoded sequences are decoded; otherwise, the returned value may contain some percent-encoded sequences for some control sequences not representable in decoded form in QString.

Note that QUrl::FullyDecoded may cause data loss if those non-representable sequences are present. It is recommended to use that value when the result will be used in a non-URL context, such as setting in QAuthenticator or negotiating a login.

See also setUserName() and userInfo().

Trait Implementations§

source§

impl CppDeletable for QUrl

source§

unsafe fn delete(&self)

Destructor; called immediately before the object is deleted.

Calls C++ function: [destructor] void QUrl::~QUrl().

C++ documentation:

Destructor; called immediately before the object is deleted.

source§

impl Lt<Ref<QUrl>> for QUrl

source§

unsafe fn lt(&self, url: &Ref<QUrl>) -> bool

Calls C++ function: bool QUrl::operator<(const QUrl& url) const.

source§

impl PartialEq<Ref<QUrl>> for QUrl

source§

fn eq(&self, url: &Ref<QUrl>) -> bool

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

Calls C++ function: bool QUrl::operator==(const QUrl& url) const.

C++ documentation:

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

1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.

Auto Trait Implementations§

§

impl RefUnwindSafe for QUrl

§

impl Send for QUrl

§

impl Sync for QUrl

§

impl Unpin for QUrl

§

impl UnwindSafe for QUrl

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T, U> CastInto<U> for T
where U: CastFrom<T>,

source§

unsafe fn cast_into(self) -> U

Performs the conversion. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> StaticUpcast<T> for T

source§

unsafe fn static_upcast(ptr: Ptr<T>) -> Ptr<T>

Convert type of a const pointer. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.