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

Readonly ComponentFormattingOption

ComponentFormattingOption: ComponentFormattingOption = ComponentFormattingOption


Readonly ParsingMode

ParsingMode: ParsingMode = ParsingMode


Readonly UrlFormattingOption

UrlFormattingOption: UrlFormattingOption = UrlFormattingOption


Readonly UserInputResolutionOption

UserInputResolutionOption: UserInputResolutionOption = UserInputResolutionOption


native

native: NativeElement

Overrides Component.native


nodeChildren

nodeChildren: Set‹Component

Inherited from Component.nodeChildren


Optional nodeParent

nodeParent? : Component

Inherited from Component.nodeParent


Static Readonly ComponentFormattingOption

ComponentFormattingOption: ComponentFormattingOption = ComponentFormattingOption


Static Readonly ParsingMode

ParsingMode: ParsingMode = ParsingMode


Static Readonly UrlFormattingOption

UrlFormattingOption: UrlFormattingOption = UrlFormattingOption


Static Readonly UserInputResolutionOption

UserInputResolutionOption: UserInputResolutionOption = UserInputResolutionOption

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


setNodeParent

setNodeParent(parent?: Component): void

Inherited from Component.setNodeParent

Parameters:

NameType
parent?Component

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?: undefined | 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?undefined | 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?: undefined | 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?undefined | string-
optionsnumberUserInputResolutionOption.DefaultResolution

Returns: QUrl