QUrl
Hierarchy
↳ QUrl
Index
Constructors
Properties
Methods
- adjusted
- authority
- clear
- errorString
- fileName
- fragment
- hasFragment
- hasQuery
- host
- isEmpty
- isLocalFile
- isParentOf
- isRelative
- isValid
- matches
- password
- path
- port
- query
- resolved
- scheme
- setAuthority
- setFragment
- setHost
- setPassword
- setPath
- setPort
- setQuery
- setScheme
- setUrl
- setUserInfo
- setUserName
- swap
- toDisplayString
- toLocalFile
- toString
- url
- userInfo
- userName
- fromLocalFile
- fromQVariant
- fromUserInput
Constructors
constructor
+ new QUrl(): QUrl
Overrides Component.constructor
Returns: QUrl
+ new QUrl(nativeElement
: NativeElement): QUrl
Overrides Component.constructor
Parameters:
Name | Type |
---|---|
nativeElement | NativeElement |
Returns: QUrl
+ new QUrl(url
: string, parsingMode?
: ParsingMode): QUrl
Overrides Component.constructor
Parameters:
Name | Type |
---|---|
url | string |
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:
Name | Type |
---|---|
options | number |
Returns: QUrl
authority
â–¸ authority(options
: number): string
Returns the authority of the URL if it is defined; otherwise an empty string is returned.
Parameters:
Name | Type | Default |
---|---|---|
options | number | ComponentFormattingOption.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:
Name | Type | Default |
---|---|---|
options | number | ComponentFormattingOption.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:
Name | Type | Default |
---|---|---|
options | number | ComponentFormattingOption.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:
Name | Type | Default |
---|---|---|
options | number | ComponentFormattingOption.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:
Name | Type |
---|---|
childUrl | QUrl |
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:
Name | Type |
---|---|
url | QUrl |
options | number |
Returns: boolean
password
â–¸ password(options
: number): string
Returns the password of the URL if it is defined; otherwise an empty string is returned.
Parameters:
Name | Type | Default |
---|---|---|
options | number | ComponentFormattingOption.FullyDecoded |
Returns: string
path
â–¸ path(options
: number): string
Returns the path of the URL.
Parameters:
Name | Type | Default |
---|---|---|
options | number | ComponentFormattingOption.FullyDecoded |
Returns: string
port
â–¸ port(defaultPort
: number): number
Returns the port of the URL, or defaultPort if the port is unspecified.
Parameters:
Name | Type | Default |
---|---|---|
defaultPort | number | -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:
Name | Type | Default |
---|---|---|
options | number | ComponentFormattingOption.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:
Name | Type |
---|---|
relative | QUrl |
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:
Name | Type | Default |
---|---|---|
authority | string | - |
mode | ParsingMode | ParsingMode.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:
Name | Type | Default |
---|---|---|
fragment | string | - |
mode | ParsingMode | ParsingMode.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:
Name | Type | Default |
---|---|---|
host | string | - |
mode | ParsingMode | ParsingMode.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:
Name | Type | Default |
---|---|---|
password | string | - |
mode | ParsingMode | ParsingMode.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:
Name | Type | Default |
---|---|---|
path | string | - |
mode | ParsingMode | ParsingMode.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:
Name | Type |
---|---|
port | number |
Returns: void
setQuery
â–¸ setQuery(query
: string, mode
: ParsingMode): void
Sets the query string of the URL to query.
Parameters:
Name | Type | Default |
---|---|---|
query | string | - |
mode | ParsingMode | ParsingMode.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:
Name | Type |
---|---|
scheme | string |
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:
Name | Type | Default |
---|---|---|
url | string | - |
parsingMode | ParsingMode | ParsingMode.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:
Name | Type | Default |
---|---|---|
userInfo | string | - |
mode | ParsingMode | ParsingMode.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:
Name | Type | Default |
---|---|---|
userName | string | - |
mode | ParsingMode | ParsingMode.DecodedMode |
Returns: void
swap
â–¸ swap(other
: QUrl): void
Swaps URL other with this URL. This operation is very fast and never fails.
Parameters:
Name | Type |
---|---|
other | QUrl |
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:
Name | Type | Default |
---|---|---|
options | number | ComponentFormattingOption.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:
Name | Type |
---|---|
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:
Name | Type |
---|---|
options | number |
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:
Name | Type | Default |
---|---|---|
options | number | ComponentFormattingOption.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:
Name | Type | Default |
---|---|---|
options | number | ComponentFormattingOption.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:
Name | Type |
---|---|
localFile | string |
Returns: QUrl
Static
fromQVariant
â–¸ fromQVariant(variant
: QVariant): QUrl
Parameters:
Name | Type |
---|---|
variant | QVariant |
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:
Name | Type | Default |
---|---|---|
userInput | string | - |
workingDirectory? | string | - |
options | number | UserInputResolutionOption.DefaultResolution |
Returns: QUrl