QUrl

Hierarchy

Index

Constructors

Properties

Methods

Constructors

constructor

+ new QUrl(): QUrl

Overrides Component.constructor

Returns: QUrl

+ new QUrl(nativeElement: NativeElement): QUrl

Overrides Component.constructor

Parameters:

NameType
nativeElementNativeElement

Returns: QUrl

+ new QUrl(url: string, parsingMode?: ParsingMode): QUrl

Overrides Component.constructor

Parameters:

NameType
urlstring
parsingMode?ParsingMode

Returns: QUrl

Properties

native

• native: NativeElement | null

Inherited from Component.native

Methods

adjusted

â–¸ adjusted(options: number): QUrl

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

Parameters:

NameType
optionsnumber

Returns: QUrl


authority

â–¸ authority(options: number): string

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

Parameters:

NameTypeDefault
optionsnumberComponentFormattingOption.PrettyDecoded

Returns: string


clear

â–¸ clear(): void

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.

Returns: void


errorString

â–¸ errorString(): string

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.

Returns: string


fileName

â–¸ fileName(options: number): string

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

Parameters:

NameTypeDefault
optionsnumberComponentFormattingOption.FullyDecoded

Returns: string


fragment

â–¸ fragment(options: number): string

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

Parameters:

NameTypeDefault
optionsnumberComponentFormattingOption.PrettyDecoded

Returns: string


hasFragment

â–¸ hasFragment(): boolean

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

Returns: boolean


hasQuery

â–¸ hasQuery(): boolean

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

Returns: boolean


host

â–¸ host(options: number): string

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

Parameters:

NameTypeDefault
optionsnumberComponentFormattingOption.FullyDecoded

Returns: string


isEmpty

â–¸ isEmpty(): boolean

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

Returns: boolean


isLocalFile

â–¸ isLocalFile(): boolean

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

Returns: boolean


isParentOf

â–¸ isParentOf(childUrl: QUrl): boolean

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.

Parameters:

NameType
childUrlQUrl

Returns: boolean


isRelative

â–¸ isRelative(): boolean

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

Returns: boolean


isValid

â–¸ isValid(): boolean

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

Returns: boolean


matches

â–¸ matches(url: QUrl, options: number): boolean

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

Parameters:

NameType
urlQUrl
optionsnumber

Returns: boolean


password

â–¸ password(options: number): string

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

Parameters:

NameTypeDefault
optionsnumberComponentFormattingOption.FullyDecoded

Returns: string


path

â–¸ path(options: number): string

Returns the path of the URL.

Parameters:

NameTypeDefault
optionsnumberComponentFormattingOption.FullyDecoded

Returns: string


port

â–¸ port(defaultPort: number): number

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

Parameters:

NameTypeDefault
defaultPortnumber-1

Returns: number


query

â–¸ query(options: number): string

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

Parameters:

NameTypeDefault
optionsnumberComponentFormattingOption.PrettyDecoded

Returns: string


resolved

â–¸ resolved(relative: QUrl): 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.

Parameters:

NameType
relativeQUrl

Returns: QUrl


scheme

â–¸ scheme(): string

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

Returns: string


setAuthority

â–¸ setAuthority(authority: string, mode: ParsingMode): void

Sets the authority of the URL to authority.

Parameters:

NameTypeDefault
authoritystring-
modeParsingModeParsingMode.TolerantMode

Returns: void


setFragment

â–¸ setFragment(fragment: string, mode: ParsingMode): void

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:

Parameters:

NameTypeDefault
fragmentstring-
modeParsingModeParsingMode.TolerantMode

Returns: void


setHost

â–¸ setHost(host: string, mode: ParsingMode): void

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

Parameters:

NameTypeDefault
hoststring-
modeParsingModeParsingMode.DecodedMode

Returns: void


setPassword

â–¸ setPassword(password: string, mode: ParsingMode): void

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

Parameters:

NameTypeDefault
passwordstring-
modeParsingModeParsingMode.DecodedMode

Returns: void


setPath

â–¸ setPath(path: string, mode: ParsingMode): void

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.

Parameters:

NameTypeDefault
pathstring-
modeParsingModeParsingMode.DecodedMode

Returns: void


setPort

â–¸ setPort(port: number): void

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

Parameters:

NameType
portnumber

Returns: void


setQuery

â–¸ setQuery(query: string, mode: ParsingMode): void

Sets the query string of the URL to query.

Parameters:

NameTypeDefault
querystring-
modeParsingModeParsingMode.TolerantMode

Returns: void


setScheme

â–¸ setScheme(scheme: string): void

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.

Parameters:

NameType
schemestring

Returns: void


setUrl

â–¸ setUrl(url: string, parsingMode: ParsingMode): void

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.

Parameters:

NameTypeDefault
urlstring-
parsingModeParsingModeParsingMode.TolerantMode

Returns: void


setUserInfo

â–¸ setUserInfo(userInfo: string, mode: ParsingMode): void

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

Parameters:

NameTypeDefault
userInfostring-
modeParsingModeParsingMode.TolerantMode

Returns: void


setUserName

â–¸ setUserName(userName: string, mode: ParsingMode): void

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

Parameters:

NameTypeDefault
userNamestring-
modeParsingModeParsingMode.DecodedMode

Returns: void


swap

â–¸ swap(other: QUrl): void

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

Parameters:

NameType
otherQUrl

Returns: void


toDisplayString

â–¸ toDisplayString(options: number): string

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.

Parameters:

NameTypeDefault
optionsnumberComponentFormattingOption.PrettyDecoded

Returns: string


toLocalFile

â–¸ toLocalFile(): string

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.

Returns: string


toString

â–¸ toString(options?: number): string

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.

See QUrl::ComponentFormattingOption for flags

Parameters:

NameType
options?number

Returns: string


url

â–¸ url(options: number): string

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.

Parameters:

NameType
optionsnumber

Returns: string


userInfo

â–¸ userInfo(options: number): string

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

Parameters:

NameTypeDefault
optionsnumberComponentFormattingOption.PrettyDecoded

Returns: string


userName

â–¸ userName(options: number): string

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

Parameters:

NameTypeDefault
optionsnumberComponentFormattingOption.FullyDecoded

Returns: string


Static fromLocalFile

â–¸ fromLocalFile(localFile: string): 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.

Parameters:

NameType
localFilestring

Returns: QUrl


Static fromQVariant

â–¸ fromQVariant(variant: QVariant): QUrl

Parameters:

NameType
variantQVariant

Returns: QUrl


Static fromUserInput

â–¸ fromUserInput(userInput: string, workingDirectory?: string, options: number): QUrl

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

Parameters:

NameTypeDefault
userInputstring-
workingDirectory?string-
optionsnumberUserInputResolutionOption.DefaultResolution

Returns: QUrl