Obsolete Members for QUrl | Qt Core 5.6

Qt 5.6 | Qt Core | C++ Classes | QUrl

Qt 5.6.2 Reference Documentation

# Obsolete Members for QUrl

The following members of class QUrl are obsolete. They are provided to keep old source code working. We strongly advise against using them in new code.

## Public Functions

`(obsolete)` void | addEncodedQueryItem(const QByteArray &key, const QByteArray &value)
`(obsolete)` void | addQueryItem(const QString &key, const QString &value)
`(obsolete)` QList<QByteArray> | allEncodedQueryItemValues(const QByteArray &key) const
`(obsolete)` QStringList | allQueryItemValues(const QString &key) const
`(obsolete)` QByteArray | encodedFragment() const
`(obsolete)` QByteArray | encodedHost() const
`(obsolete)` QByteArray | encodedPassword() const
`(obsolete)` QByteArray | encodedPath() const
`(obsolete)` QByteArray | encodedQuery() const
`(obsolete)` QByteArray | encodedQueryItemValue(const QByteArray &key) const
`(obsolete)` QList<QPair<QByteArray, QByteArray> > | encodedQueryItems() const
`(obsolete)` QByteArray | encodedUserName() const
`(obsolete)` bool | hasEncodedQueryItem(const QByteArray &key) const
`(obsolete)` bool | hasQueryItem(const QString &key) const
`(obsolete)` QString | queryItemValue(const QString &key) const
`(obsolete)` QList<QPair<QString, QString> > | queryItems() const
`(obsolete)` void | removeAllEncodedQueryItems(const QByteArray &key)
`(obsolete)` void | removeAllQueryItems(const QString &key)
`(obsolete)` void | removeEncodedQueryItem(const QByteArray &key)
`(obsolete)` void | removeQueryItem(const QString &key)
`(obsolete)` void | setEncodedFragment(const QByteArray &fragment)
`(obsolete)` void | setEncodedHost(const QByteArray &host)
`(obsolete)` void | setEncodedPassword(const QByteArray &password)
`(obsolete)` void | setEncodedPath(const QByteArray &path)
`(obsolete)` void | setEncodedQuery(const QByteArray &query)
`(obsolete)` void | setEncodedQueryItems(const QList<QPair<QByteArray, QByteArray> > &query)
`(obsolete)` void | setEncodedUrl(const QByteArray &encodedUrl, ParsingMode parsingMode = TolerantMode)
`(obsolete)` void | setEncodedUserName(const QByteArray &userName)
`(obsolete)` void | setQueryItems(const QList<QPair<QString, QString> > &query)

## Static Public Members

`(obsolete)` QString | fromPunycode(const QByteArray &pc)
`(obsolete)` QByteArray | toPunycode(const QString &uc)

## Member Function Documentation

### void QUrl::addEncodedQueryItem(const QByteArray &key, const QByteArray &value)

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

This function was introduced in Qt 4.4.

See also addQueryItem().

### void QUrl::addQueryItem(const QString &key, const QString &value)

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

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

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

See also addEncodedQueryItem().

### QList<QByteArray> QUrl::allEncodedQueryItemValues(const QByteArray &key) const

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

This function was introduced in Qt 4.4.

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

### QStringList QUrl::allQueryItemValues(const QString &key) const

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

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

See also queryItemValue().

### QByteArray QUrl::encodedFragment() const

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

This function was introduced in Qt 4.4.

See also setEncodedFragment() and toEncoded().

### QByteArray QUrl::encodedHost() const

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

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

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

This function was introduced in Qt 4.4.

See also setEncodedHost().

### QByteArray QUrl::encodedPassword() const

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

This function was introduced in Qt 4.4.

See also setEncodedPassword() and toEncoded().

### QByteArray QUrl::encodedPath() const

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

This function was introduced in Qt 4.4.

See also setEncodedPath() and toEncoded().

### QByteArray QUrl::encodedQuery() const

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

See also setEncodedQuery() and query().

### QByteArray QUrl::encodedQueryItemValue(const QByteArray &key) const

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

This function was introduced in Qt 4.4.

See also queryItemValue() and allQueryItemValues().

### QList<QPair<QByteArray, QByteArray> > QUrl::encodedQueryItems() const

Returns the query string of the URL, as a map of encoded keys and values.

This function was introduced in Qt 4.4.

See also setEncodedQueryItems(), setQueryItems(), and setEncodedQuery().

### QByteArray QUrl::encodedUserName() const

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

This function was introduced in Qt 4.4.

See also setEncodedUserName().

### `[static]` QString QUrl::fromPunycode(const QByteArray &pc)

Returns the Punycode decoded representation of pc.

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

### bool QUrl::hasEncodedQueryItem(const QByteArray &key) const

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

This function was introduced in Qt 4.4.

See also hasQueryItem().

### bool QUrl::hasQueryItem(const QString &key) const

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

See also hasEncodedQueryItem().

### QString QUrl::queryItemValue(const QString &key) const

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

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

See also allQueryItemValues().

### QList<QPair<QString, QString> > QUrl::queryItems() const

Returns the query string of the URL, as a map of keys and values.

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

See also setQueryItems() and setEncodedQuery().

### void QUrl::removeAllEncodedQueryItems(const QByteArray &key)

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

This function was introduced in Qt 4.4.

See also removeQueryItem().

### void QUrl::removeAllQueryItems(const QString &key)

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

See also removeQueryItem().

### void QUrl::removeEncodedQueryItem(const QByteArray &key)

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

This function was introduced in Qt 4.4.

See also removeQueryItem() and removeAllQueryItems().

### void QUrl::removeQueryItem(const QString &key)

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

See also removeAllQueryItems().

### void QUrl::setEncodedFragment(const QByteArray &fragment)

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

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

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

This function was introduced in Qt 4.4.

See also setFragment() and encodedFragment().

### void QUrl::setEncodedHost(const QByteArray &host)

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

This function was introduced in Qt 4.4.

See also setHost(), encodedHost(), setAuthority(), and fromAce().

### void QUrl::setEncodedPassword(const QByteArray &password)

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

This function was introduced in Qt 4.4.

See also setPassword(), encodedPassword(), and setUserInfo().

### void QUrl::setEncodedPath(const QByteArray &path)

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

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

This function was introduced in Qt 4.4.

See also setPath(), encodedPath(), and setUserInfo().

### void QUrl::setEncodedQuery(const QByteArray &query)

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

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

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

See also encodedQuery() and hasQuery().

### void QUrl::setEncodedQueryItems(const QList<QPair<QByteArray, QByteArray> > &query)

Sets the query string of the URL to the encoded version of query. The contents of query are converted to a string internally, each pair delimited by the character returned by queryPairDelimiter(), and the key and value are delimited by queryValueDelimiter().

This function was introduced in Qt 4.4.

See also encodedQueryItems() and setQueryItems().

### void QUrl::setEncodedUrl(const QByteArray &encodedUrl, ParsingMode parsingMode = TolerantMode)

Constructs a URL by parsing the contents of encodedUrl.

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

The parsing mode parsingMode is used for parsing encodedUrl.

See also setUrl().

### void QUrl::setEncodedUserName(const QByteArray &userName)

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

This function was introduced in Qt 4.4.

See also setUserName(), encodedUserName(), and setUserInfo().

### void QUrl::setQueryItems(const QList<QPair<QString, QString> > &query)

Sets the query string of the URL to an encoded version of query. The contents of query are converted to a string internally, each pair delimited by the character returned by queryPairDelimiter(), and the key and value are delimited by queryValueDelimiter()

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

See also queryItems() and setEncodedQueryItems().

### `[static]` QByteArray QUrl::toPunycode(const QString &uc)

Returns a uc in Punycode encoding.

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