|  | Home · All Classes · Modules

# QUrlInfo Class Reference
[QtNetwork module]

The QUrlInfo class stores information about URLs. More...

### Types

- enum PermissionSpec { ReadOwner, WriteOwner, ExeOwner, ReadGroup, ..., ExeOther }

### Methods

- __init__ (self)
- __init__ (self, QUrlInfo ui)
- __init__ (self, QString name, int permissions, QString owner, QString group, long size, QDateTime lastModified, QDateTime lastRead, bool isDir, bool isFile, bool isSymLink, bool isWritable, bool isReadable, bool isExecutable)
- __init__ (self, QUrl url, int permissions, QString owner, QString group, long size, QDateTime lastModified, QDateTime lastRead, bool isDir, bool isFile, bool isSymLink, bool isWritable, bool isReadable, bool isExecutable)
- QString group (self)
- bool isDir (self)
- bool isExecutable (self)
- bool isFile (self)
- bool isReadable (self)
- bool isSymLink (self)
- bool isValid (self)
- bool isWritable (self)
- QDateTime lastModified (self)
- QDateTime lastRead (self)
- QString name (self)
- QString owner (self)
- int permissions (self)
- setDir (self, bool b)
- setFile (self, bool b)
- setGroup (self, QString s)
- setLastModified (self, QDateTime dt)
- setLastRead (self, QDateTime dt)
- setName (self, QString name)
- setOwner (self, QString s)
- setPermissions (self, int p)
- setReadable (self, bool b)
- setSize (self, long size)
- setSymLink (self, bool b)
- setWritable (self, bool b)
- long size (self)

### Static Methods

- bool equal (QUrlInfo i1, QUrlInfo i2, int sortBy)
- bool greaterThan (QUrlInfo i1, QUrlInfo i2, int sortBy)
- bool lessThan (QUrlInfo i1, QUrlInfo i2, int sortBy)

### Special Methods

- bool __eq__ (self, QUrlInfo i)
- bool __ne__ (self, QUrlInfo i)

## Detailed Description

The QUrlInfo class stores information about URLs.

The information about a URL that can be retrieved includes name(), permissions(), owner(), group(), size(), lastModified(), lastRead(), isDir(), isFile(), isSymLink(), isWritable(), isReadable() and isExecutable().

You can create your own QUrlInfo objects passing in all the relevant information in the constructor, and you can modify a QUrlInfo; for each getter mentioned above there is an equivalent setter. Note that setting values does not affect the underlying resource that the QUrlInfo provides information about; for example if you call setWritable(true) on a read-only resource the only thing changed is the QUrlInfo object, not the resource.

See also QUrl and FTP Example.

## Type Documentation

### QUrlInfo.PermissionSpec

This enum is used by the permissions() function to report the permissions of a file.

Constant | Value | Description
--- | --- | ---
`QUrlInfo.ReadOwner` | `00400` | The file is readable by the owner of the file.
`QUrlInfo.WriteOwner` | `00200` | The file is writable by the owner of the file.
`QUrlInfo.ExeOwner` | `00100` | The file is executable by the owner of the file.
`QUrlInfo.ReadGroup` | `00040` | The file is readable by the group.
`QUrlInfo.WriteGroup` | `00020` | The file is writable by the group.
`QUrlInfo.ExeGroup` | `00010` | The file is executable by the group.
`QUrlInfo.ReadOther` | `00004` | The file is readable by anyone.
`QUrlInfo.WriteOther` | `00002` | The file is writable by anyone.
`QUrlInfo.ExeOther` | `00001` | The file is executable by anyone.

## Method Documentation

### QUrlInfo.__init__ (self)

Constructs an invalid QUrlInfo object with default values.

See also isValid().

### QUrlInfo.__init__ (self, QUrlInfo ui)

Copy constructor, copies ui to this URL info object.

### QUrlInfo.__init__ (self, QString name, int permissions, QString owner, QString group, long size, QDateTime lastModified, QDateTime lastRead, bool isDir, bool isFile, bool isSymLink, bool isWritable, bool isReadable, bool isExecutable)

Constructs a QUrlInfo object by specifying all the URL's information.

The information that is passed is the name, file permissions, owner and group and the file's size. Also passed is the lastModified date/time and the lastRead date/time. Flags are also passed, specifically, isDir, isFile, isSymLink, isWritable, isReadable and isExecutable.

### QUrlInfo.__init__ (self, QUrl url, int permissions, QString owner, QString group, long size, QDateTime lastModified, QDateTime lastRead, bool isDir, bool isFile, bool isSymLink, bool isWritable, bool isReadable, bool isExecutable)

Constructs a QUrlInfo object by specifying all the URL's information.

The information that is passed is the url, file permissions, owner and group and the file's size. Also passed is the lastModified date/time and the lastRead date/time. Flags are also passed, specifically, isDir, isFile, isSymLink, isWritable, isReadable and isExecutable.

### bool QUrlInfo.equal (QUrlInfo i1, QUrlInfo i2, int sortBy)

Returns true if i1 equals to i2; otherwise returns false. The objects are compared by the value, which is specified by sortBy. This must be one of QDir.Name, QDir.Time or QDir.Size.

### bool QUrlInfo.greaterThan (QUrlInfo i1, QUrlInfo i2, int sortBy)

Returns true if i1 is greater than i2; otherwise returns false. The objects are compared by the value, which is specified by sortBy. This must be one of QDir.Name, QDir.Time or QDir.Size.

### QString QUrlInfo.group (self)

Returns the group of the URL.

See also setGroup() and isValid().

### bool QUrlInfo.isDir (self)

Returns true if the URL is a directory; otherwise returns false.

See also isValid().

### bool QUrlInfo.isExecutable (self)

Returns true if the URL is executable; otherwise returns false.

See also isValid().

### bool QUrlInfo.isFile (self)

Returns true if the URL is a file; otherwise returns false.

See also isValid().

### bool QUrlInfo.isReadable (self)

Returns true if the URL is readable; otherwise returns false.

See also isValid().

### bool QUrlInfo.isSymLink (self)

Returns true if the URL is a symbolic link; otherwise returns false.

See also isValid().

### bool QUrlInfo.isValid (self)

Returns true if the URL info is valid; otherwise returns false. Valid means that the QUrlInfo contains real information.

You should always check if the URL info is valid before relying on the values.

### bool QUrlInfo.isWritable (self)

Returns true if the URL is writable; otherwise returns false.

See also isValid().

### QDateTime QUrlInfo.lastModified (self)

Returns the last modification date of the URL.

See also setLastModified() and isValid().

### QDateTime QUrlInfo.lastRead (self)

Returns the date when the URL was last read.

See also setLastRead() and isValid().

### bool QUrlInfo.lessThan (QUrlInfo i1, QUrlInfo i2, int sortBy)

Returns true if i1 is less than i2; otherwise returns false. The objects are compared by the value, which is specified by sortBy. This must be one of QDir.Name, QDir.Time or QDir.Size.

### QString QUrlInfo.name (self)

Returns the file name of the URL.

See also setName() and isValid().

### QString QUrlInfo.owner (self)

Returns the owner of the URL.

See also setOwner() and isValid().

### int QUrlInfo.permissions (self)

Returns the permissions of the URL. You can use the `PermissionSpec` flags to test for certain permissions.

See also setPermissions() and isValid().

### QUrlInfo.setDir (self, bool b)

If b is true then the URL is set to be a directory; if b is false then the URL is set not to be a directory (which normally means it is a file). (Note that a URL can refer to both a file and a directory even though most file systems do not support this.)

If you call this function for an invalid URL info, this function turns it into a valid one.

See also isDir() and isValid().

### QUrlInfo.setFile (self, bool b)

If b is true then the URL is set to be a file; if \b is false then the URL is set not to be a file (which normally means it is a directory). (Note that a URL can refer to both a file and a directory even though most file systems do not support this.)

If you call this function for an invalid URL info, this function turns it into a valid one.

See also isFile() and isValid().

### QUrlInfo.setGroup (self, QString s)

Specifies that the owning group of the URL is called s.

If you call this function for an invalid URL info, this function turns it into a valid one.

See also group() and isValid().

### QUrlInfo.setLastModified (self, QDateTime dt)

Specifies that the object the URL refers to was last modified at dt.

If you call this function for an invalid URL info, this function turns it into a valid one.

See also lastModified() and isValid().

### QUrlInfo.setLastRead (self, QDateTime dt)

Specifies that the object the URL refers to was last read at dt.

If you call this function for an invalid URL info, this function turns it into a valid one.

This function was introduced in Qt 4.4.

See also lastRead() and isValid().

### QUrlInfo.setName (self, QString name)

Sets the name of the URL to name. The name is the full text, for example, "http://doc.trolltech.com/qurlinfo.html".

If you call this function for an invalid URL info, this function turns it into a valid one.

See also name() and isValid().

### QUrlInfo.setOwner (self, QString s)

Specifies that the owner of the URL is called s.

If you call this function for an invalid URL info, this function turns it into a valid one.

See also owner() and isValid().

### QUrlInfo.setPermissions (self, int p)

Specifies that the URL has access permissions p.

If you call this function for an invalid URL info, this function turns it into a valid one.

See also permissions() and isValid().

### QUrlInfo.setReadable (self, bool b)

Specifies that the URL is readable if b is true and not readable if b is false.

If you call this function for an invalid URL info, this function turns it into a valid one.

See also isReadable() and isValid().

### QUrlInfo.setSize (self, long size)

Specifies the size of the URL.

If you call this function for an invalid URL info, this function turns it into a valid one.

See also size() and isValid().

### QUrlInfo.setSymLink (self, bool b)

Specifies that the URL refers to a symbolic link if b is true and that it does not if b is false.

If you call this function for an invalid URL info, this function turns it into a valid one.

See also isSymLink() and isValid().

### QUrlInfo.setWritable (self, bool b)

Specifies that the URL is writable if b is true and not writable if b is false.

If you call this function for an invalid URL info, this function turns it into a valid one.

See also isWritable() and isValid().

### long QUrlInfo.size (self)

Returns the size of the URL.

See also setSize() and isValid().

### bool QUrlInfo.__eq__ (self, QUrlInfo i)

### bool QUrlInfo.__ne__ (self, QUrlInfo i)