Eneboo - Documentación para desarrolladores
Métodos públicos | Métodos públicos estáticos | Métodos protegidos
Referencia de la Clase QUrl

The QUrl class provides a URL parser and simplifies working with URLs.. Más...

#include <qurl.h>

Diagrama de herencias de QUrl
QUrlOperator QUrlOperator

Lista de todos los miembros.

Métodos públicos

 QUrl ()
 QUrl (const QString &url)
 QUrl (const QUrl &url)
 QUrl (const QUrl &url, const QString &relUrl, bool checkSlash=FALSE)
virtual ~QUrl ()
QString protocol () const
virtual void setProtocol (const QString &protocol)
QString user () const
virtual void setUser (const QString &user)
bool hasUser () const
QString password () const
virtual void setPassword (const QString &pass)
bool hasPassword () const
QString host () const
virtual void setHost (const QString &user)
bool hasHost () const
int port () const
virtual void setPort (int port)
bool hasPort () const
QString path (bool correct=TRUE) const
virtual void setPath (const QString &path)
bool hasPath () const
virtual void setEncodedPathAndQuery (const QString &enc)
QString encodedPathAndQuery ()
virtual void setQuery (const QString &txt)
QString query () const
QString ref () const
virtual void setRef (const QString &txt)
bool hasRef () const
bool isValid () const
bool isLocalFile () const
virtual void addPath (const QString &path)
virtual void setFileName (const QString &txt)
QString fileName () const
QString dirPath () const
QUrloperator= (const QUrl &url)
QUrloperator= (const QString &url)
bool operator== (const QUrl &url) const
bool operator== (const QString &url) const
 operator QString () const
virtual QString toString (bool encodedPath=FALSE, bool forcePrependProtocol=TRUE) const
virtual bool cdUp ()
 QUrl ()
 QUrl (const QString &url)
 QUrl (const QUrl &url)
 QUrl (const QUrl &url, const QString &relUrl, bool checkSlash=FALSE)
virtual ~QUrl ()
QString protocol () const
virtual void setProtocol (const QString &protocol)
QString user () const
virtual void setUser (const QString &user)
bool hasUser () const
QString password () const
virtual void setPassword (const QString &pass)
bool hasPassword () const
QString host () const
virtual void setHost (const QString &user)
bool hasHost () const
int port () const
virtual void setPort (int port)
bool hasPort () const
QString path (bool correct=TRUE) const
virtual void setPath (const QString &path)
bool hasPath () const
virtual void setEncodedPathAndQuery (const QString &enc)
QString encodedPathAndQuery ()
virtual void setQuery (const QString &txt)
QString query () const
QString ref () const
virtual void setRef (const QString &txt)
bool hasRef () const
bool isValid () const
bool isLocalFile () const
virtual void addPath (const QString &path)
virtual void setFileName (const QString &txt)
QString fileName () const
QString dirPath () const
QUrloperator= (const QUrl &url)
QUrloperator= (const QString &url)
bool operator== (const QUrl &url) const
bool operator== (const QString &url) const
 operator QString () const
virtual QString toString (bool encodedPath=FALSE, bool forcePrependProtocol=TRUE) const
virtual bool cdUp ()

Métodos públicos estáticos

static void decode (QString &url)
static void encode (QString &url)
static bool isRelativeUrl (const QString &url)
static void decode (QString &url)
static void encode (QString &url)
static bool isRelativeUrl (const QString &url)

Métodos protegidos

virtual void reset ()
virtual bool parse (const QString &url)
virtual void reset ()
virtual bool parse (const QString &url)

Descripción detallada

The QUrl class provides a URL parser and simplifies working with URLs.

.

network

The QUrl class is provided for simple work with URLs. It can parse, decode, encode, etc.

QUrl works with the decoded path and encoded query in turn.

Example:

http://www.trolltech.com:80/cgi-bin/test%20me.pl?cmd=Hello%20you

Function Returns protocol() "http" host() "www.trolltech.com" port() 80 path() "/cgi-bin/test&nbsp;me.pl" fileName() "test&nbsp;me.pl" query() "cmd=Hello%20you"

Example:

http://doc.trolltech.com/qdockarea.html#lines

Function Returns protocol() "http" host() "doc.trolltech.com" fileName() "qdockarea.html" ref() "lines"

The individual parts of a URL can be set with setProtocol(), setHost(), setPort(), setPath(), setFileName(), setRef() and setQuery(). A URL could contain, for example, an ftp address which requires a user name and password; these can be set with setUser() and setPassword().

Because path is always encoded internally you must not use "%00" in the path, although this is okay (but not recommended) for the query.

QUrl is normally used like this:

    QUrl url( "http://www.trolltech.com" );
    // or
    QUrl url( "file:/home/myself/Mail", "Inbox" );

You can then access and manipulate the various parts of the URL.

To make it easy to work with QUrls and QStrings, QUrl implements the necessary cast and assignment operators so you can do following:

    QUrl url( "http://www.trolltech.com" );
    QString s = url;
    // or
    QString s( "http://www.trolltech.com" );
    QUrl url( s );

Use the static functions, encode() and decode() to encode or decode a URL in a string. (They operate on the string in-place.) The isRelativeUrl() static function returns TRUE if the given string is a relative URL.

If you want to use a URL to work on a hierarchical structure (e.g. a local or remote filesystem), you might want to use the subclass QUrlOperator.

Ver también:
QUrlOperator

Documentación del constructor y destructor

QUrl::QUrl ( )

Constructs an empty URL that is invalid.

QUrl::QUrl ( const QString url)

Constructs a URL by parsing the string url.

If you pass a string like "/home/qt", the "file" protocol is assumed.

QUrl::QUrl ( const QUrl url)

Copy constructor. Copies the data of url.

QUrl::QUrl ( const QUrl url,
const QString relUrl,
bool  checkSlash = FALSE 
)

Constructs an URL taking url as the base (context) and relUrl as a relative URL to url. If relUrl is not relative, relUrl is taken as the new URL.

For example, the path of

    QUrl url( "ftp://ftp.trolltech.com/qt/source", "qt-2.1.0.tar.gz" );

will be "/qt/srource/qt-2.1.0.tar.gz".

On the other hand,

    QUrl url( "ftp://ftp.trolltech.com/qt/source", "/usr/local" );

will result in a new URL, "ftp://ftp.trolltech.com/usr/local", because "/usr/local" isn't relative.

Similarly,

    QUrl url( "ftp://ftp.trolltech.com/qt/source", "file:/usr/local" );

will result in a new URL, with "/usr/local" as the path and "file" as the protocol.

Normally it is expected that the path of url points to a directory, even if the path has no slash at the end. But if you want the constructor to handle the last part of the path as a file name if there is no slash at the end, and to let it be replaced by the file name of relUrl (if it contains one), set checkSlash to TRUE.

QUrl::~QUrl ( ) [virtual]

Destructor.

QUrl::QUrl ( )
QUrl::QUrl ( const QString url)
QUrl::QUrl ( const QUrl url)
QUrl::QUrl ( const QUrl url,
const QString relUrl,
bool  checkSlash = FALSE 
)
virtual QUrl::~QUrl ( ) [virtual]

Documentación de las funciones miembro

void QUrl::addPath ( const QString pa) [virtual]

Adds the path pa to the path of the URL.

Ver también:
setPath() hasPath()
virtual void QUrl::addPath ( const QString path) [virtual]
bool QUrl::cdUp ( ) [virtual]

Changes the directory to one directory up.

Ver también:
setPath()

Reimplementado en QUrlOperator y QUrlOperator.

virtual bool QUrl::cdUp ( ) [virtual]

Reimplementado en QUrlOperator y QUrlOperator.

void QUrl::decode ( QString url) [static]

Decodes the url in-place into UTF-8. For example

        QString url = "http%3A//www%20trolltech%20com"
        QUrl::decode( url );
        // url is now "http://www.trolltech.com"
Ver también:
encode()
static void QUrl::decode ( QString url) [static]
QString QUrl::dirPath ( ) const
QString QUrl::dirPath ( ) const

Returns the directory path of the URL. This is the part of the path of the URL without the fileName(). See the documentation of fileName() for a discussion of what is handled as file name and what is handled as directory path.

Ver también:
setPath() hasPath()
void QUrl::encode ( QString url) [static]

Encodes the url in-place into UTF-8. For example

        QString url = http://www.trolltech.com
        QUrl::encode( url );
        // url is now "http%3A//www%20trolltech%20com"
Ver también:
decode()
static void QUrl::encode ( QString url) [static]
QString QUrl::encodedPathAndQuery ( )

Returns the encoded path and query.

Ver también:
decode()
QString QUrl::encodedPathAndQuery ( )
QString QUrl::fileName ( ) const
QString QUrl::fileName ( ) const

Returns the file name of the URL. If the path of the URL doesn't have a slash at the end, the part between the last slash and the end of the path string is considered to be the file name. If the path has a slash at the end, an empty string is returned here.

Ver también:
setFileName()
bool QUrl::hasHost ( ) const

Returns TRUE if the URL contains a hostname; otherwise returns FALSE.

Ver también:
setHost()
bool QUrl::hasHost ( ) const
bool QUrl::hasPassword ( ) const

Returns TRUE if the URL contains a password; otherwise returns FALSE.

Atención:
Passwords passed in URLs are normally insecure; this is due to the mechanism, not because of Qt.
Ver también:
setPassword() setUser()
bool QUrl::hasPassword ( ) const
bool QUrl::hasPath ( ) const

Returns TRUE if the URL contains a path; otherwise returns FALSE.

Ver también:
path() setPath()
bool QUrl::hasPath ( ) const
bool QUrl::hasPort ( ) const

Returns TRUE if the URL contains a port; otherwise returns FALSE.

Ver también:
setPort()
bool QUrl::hasPort ( ) const
bool QUrl::hasRef ( ) const
bool QUrl::hasRef ( ) const

Returns TRUE if the URL has a reference; otherwise returns FALSE.

Ver también:
setRef()
bool QUrl::hasUser ( ) const

Returns TRUE if the URL contains a username; otherwise returns FALSE.

Ver también:
setUser() setPassword()
bool QUrl::hasUser ( ) const
QString QUrl::host ( ) const

Returns the hostname of the URL.

Ver también:
setHost() hasHost()
QString QUrl::host ( ) const
bool QUrl::isLocalFile ( ) const
bool QUrl::isLocalFile ( ) const

Returns TRUE if the URL is a local file; otherwise returns FALSE.

bool QUrl::isRelativeUrl ( const QString url) [static]

Returns TRUE if url is relative; otherwise returns FALSE.

static bool QUrl::isRelativeUrl ( const QString url) [static]
bool QUrl::isValid ( ) const
bool QUrl::isValid ( void  ) const

Returns TRUE if the URL is valid; otherwise returns FALSE. A URL is invalid if it cannot be parsed, for example.

QUrl::operator QString ( ) const

Composes a string version of the URL and returns it.

Ver también:
QUrl::toString()
QUrl::operator QString ( ) const
QUrl & QUrl::operator= ( const QString url)

Esta es una función miembro sobrecargada que se suministra por conveniencia. Difiere de la anterior función solamente en los argumentos que acepta. Parses url and assigns the resulting data to this class.

If you pass a string like "/home/qt" the "file" protocol will be assumed.

Reimplementado en QUrlOperator y QUrlOperator.

QUrl& QUrl::operator= ( const QUrl url)
QUrl& QUrl::operator= ( const QString url)

Reimplementado en QUrlOperator y QUrlOperator.

QUrl & QUrl::operator= ( const QUrl url)

Assigns the data of url to this class.

bool QUrl::operator== ( const QString url) const

Esta es una función miembro sobrecargada que se suministra por conveniencia. Difiere de la anterior función solamente en los argumentos que acepta. Compares this URL with url. url is parsed first. Returns TRUE if url is equal to this url; otherwise returns FALSE.

bool QUrl::operator== ( const QString url) const
bool QUrl::operator== ( const QUrl url) const

Compares this URL with url and returns TRUE if they are equal; otherwise returns FALSE.

bool QUrl::operator== ( const QUrl url) const
bool QUrl::parse ( const QString url) [protected, virtual]

Parses the url.

Reimplementado en QUrlOperator y QUrlOperator.

virtual bool QUrl::parse ( const QString url) [protected, virtual]

Reimplementado en QUrlOperator y QUrlOperator.

QString QUrl::password ( ) const
QString QUrl::password ( ) const

Returns the password of the URL.

Atención:
Passwords passed in URLs are normally insecure; this is due to the mechanism, not because of Qt.
Ver también:
setPassword() setUser()
QString QUrl::path ( bool  correct = TRUE) const
QString QUrl::path ( bool  correct = TRUE) const

Returns the path of the URL. If correct is TRUE, the path is cleaned (deals with too many or too few slashes, cleans things like "/../..", etc). Otherwise path() returns exactly the path that was parsed or set.

Ver también:
setPath() hasPath()
int QUrl::port ( ) const

Returns the port of the URL or -1 if no port has been set.

Ver también:
setPort()
int QUrl::port ( ) const
QString QUrl::protocol ( ) const

Returns the protocol of the URL. Typically, "file", "http", "ftp", etc.

Ver también:
setProtocol()
QString QUrl::protocol ( ) const
QString QUrl::query ( ) const

Returns the (encoded) query of the URL.

Ver también:
setQuery() decode()
QString QUrl::query ( ) const
QString QUrl::ref ( ) const
QString QUrl::ref ( ) const

Returns the (encoded) reference of the URL.

Ver también:
setRef() hasRef() decode()
void QUrl::reset ( void  ) [protected, virtual]

Resets all parts of the URL to their default values and invalidates it.

Reimplementado en QUrlOperator y QUrlOperator.

virtual void QUrl::reset ( ) [protected, virtual]

Reimplementado en QUrlOperator y QUrlOperator.

virtual void QUrl::setEncodedPathAndQuery ( const QString enc) [virtual]
void QUrl::setEncodedPathAndQuery ( const QString pathAndQuery) [virtual]

Parses pathAndQuery for a path and query and sets those values. The whole string must be encoded.

Ver también:
encode()
virtual void QUrl::setFileName ( const QString txt) [virtual]
void QUrl::setFileName ( const QString name) [virtual]

Sets the file name of the URL to name. If this URL contains a fileName(), the original file name is replaced by name.

See the documentation of fileName() for a more detailed discussion of what is handled as file name and what is handled as a directory path.

Ver también:
fileName()
virtual void QUrl::setHost ( const QString user) [virtual]
void QUrl::setHost ( const QString host) [virtual]

Sets the hostname of the URL to host.

Ver también:
host() hasHost()
virtual void QUrl::setPassword ( const QString pass) [virtual]
void QUrl::setPassword ( const QString pass) [virtual]

Sets the password of the URL to pass.

Atención:
Passwords passed in URLs are normally insecure; this is due to the mechanism, not because of Qt.
Ver también:
password() setUser()
virtual void QUrl::setPath ( const QString path) [virtual]

Reimplementado en QUrlOperator y QUrlOperator.

void QUrl::setPath ( const QString path) [virtual]

Sets the path of the URL to path.

Ver también:
path() hasPath()

Reimplementado en QUrlOperator y QUrlOperator.

virtual void QUrl::setPort ( int  port) [virtual]
void QUrl::setPort ( int  port) [virtual]

Sets the port of the URL to port.

Ver también:
port()
virtual void QUrl::setProtocol ( const QString protocol) [virtual]
void QUrl::setProtocol ( const QString protocol) [virtual]

Sets the protocol of the URL to protocol. Typically, "file", "http", "ftp", etc.

Ver también:
protocol()
virtual void QUrl::setQuery ( const QString txt) [virtual]
void QUrl::setQuery ( const QString txt) [virtual]

Sets the query of the URL to txt. txt must be encoded.

Ver también:
query() encode()
void QUrl::setRef ( const QString txt) [virtual]

Sets the reference of the URL to txt. txt must be encoded.

Ver también:
ref() hasRef() encode()
virtual void QUrl::setRef ( const QString txt) [virtual]
void QUrl::setUser ( const QString user) [virtual]

Sets the username of the URL to user.

Ver también:
user() setPassword()
virtual void QUrl::setUser ( const QString user) [virtual]
virtual QString QUrl::toString ( bool  encodedPath = FALSE,
bool  forcePrependProtocol = TRUE 
) const [virtual]
QString QUrl::toString ( bool  encodedPath = FALSE,
bool  forcePrependProtocol = TRUE 
) const [virtual]

Composes a string version of the URL and returns it. If encodedPath is TRUE the path in the returned string is encoded. If forcePrependProtocol is TRUE and encodedPath looks like a local filename, the "file:/" protocol is also prepended.

Ver también:
encode() decode()
QString QUrl::user ( ) const

Returns the username of the URL.

Ver también:
setUser() setPassword()
QString QUrl::user ( ) const

La documentación para esta clase fue generada a partir de los siguientes ficheros:
 Todo Clases Namespaces Archivos Funciones Variables 'typedefs' Enumeraciones Valores de enumeraciones Propiedades Amigas 'defines'