QDir

概要

函数

静态函数

详细描述

PySide.QtCore.QDir class provides access to directory structures and their contents.

A PySide.QtCore.QDir is used to manipulate path names, access information regarding paths and files, and manipulate the underlying file system. It can also be used to access Qt's 资源系统 .

Qt uses “/” as a universal directory separator in the same way that “/” is used as a path separator in URLs. If you always use “/” as a directory separator, Qt will translate your paths to conform to the underlying operating system.

A PySide.QtCore.QDir can point to a file using either a relative or an absolute path. Absolute paths begin with the directory separator (optionally preceded by a drive specification under Windows). Relative file names begin with a directory name or a file name and specify a path relative to the current directory.

Examples of absolute paths:

QDir("/home/user/Documents")
QDir("C:/Documents and Settings")
										

On Windows, the second example above will be translated to C:\Documents and 设置 when used to access files.

Examples of relative paths:

QDir("images/landscape.png")
										

可以使用 PySide.QtCore.QDir.isRelative() or PySide.QtCore.QDir.isAbsolute() functions to check if a PySide.QtCore.QDir is using a relative or an absolute file path. Call PySide.QtCore.QDir.makeAbsolute() to convert a relative PySide.QtCore.QDir to an absolute one.