Viadeo Twitter Google Bookmarks ! Facebook Digg del.icio.us MySpace Yahoo MyWeb Blinklist Netvouz Reddit Simpy StumbleUpon Bookmarks Windows Live Favorites 
Logo Documentation Qt ·  Page d'accueil  ·  Toutes les classes  ·  Classes principales  ·  Annotées  ·  Classes groupées  ·  Modules  ·  Fonctions  · 

QMimeType Class

The QMimeType class describes types of file or data, represented by a MIME type string. More...

 #include <QMimeType>

This class was introduced in Qt 5.0.

Public Functions

QMimeType()
QMimeType(const QMimeType & other)
QMimeType(const QMimeTypePrivate & dd)
~QMimeType()
QStringList allAncestors() const
QString comment() const
QString filterString() const
QString genericIconName() const
QStringList globPatterns() const
QString iconName() const
bool inherits(const QString & mimeTypeName) const
bool isDefault() const
bool isValid() const
QString name() const
QStringList parentMimeTypes() const
QString preferredSuffix() const
QStringList suffixes() const
void swap(QMimeType & other)
bool operator!=(const QMimeType & other) const
QMimeType & operator=(const QMimeType & other)
bool operator==(const QMimeType & other) const

Detailed Description

The QMimeType class describes types of file or data, represented by a MIME type string.

For instance a file named "readme.txt" has the MIME type "text/plain". The MIME type can be determined from the file name, or from the file contents, or from both. MIME type determination can also be done on buffers of data not coming from files.

Determining the MIME type of a file can be useful to make sure your application supports it. It is also useful in file-manager-like applications or widgets, in order to display an appropriate icon() for the file, or even the descriptive comment() in detailed views.

To check if a file has the expected MIME type, you should use inherits() rather than a simple string comparison based on the name(). This is because MIME types can inherit from each other: for instance a C source file is a specific type of plain text file, so text/x-csrc inherits text/plain.

See also QMimeDatabase.

Member Function Documentation

QMimeType::QMimeType()

Constructs this QMimeType object initialized with default property values that indicate an invalid MIME type.

QMimeType::QMimeType(const QMimeType & other)

Constructs this QMimeType object as a copy of other.

QMimeType::QMimeType(const QMimeTypePrivate & dd)

Assigns the data of the QMimeTypePrivate dd to this QMimeType object, and returns a reference to this object.

QMimeType::~QMimeType()

Destroys the QMimeType object, and releases the d pointer.

QStringList QMimeType::allAncestors() const

Return all the parent mimetypes of this mimetype, direct and indirect. This includes the parent(s) of its parent(s), etc.

For instance, for image/svg+xml the list would be: application/xml, text/plain, application/octet-stream.

Note that application/octet-stream is the ultimate parent for all types of files (but not directories).

QString QMimeType::comment() const

Returns the description of the MIME type to be displayed on user interfaces.

The system language (QLocale::system().name()) is used to select the appropriate translation.

QString QMimeType::filterString() const

Returns a filter string usable for a file dialog.

QString QMimeType::genericIconName() const

Returns the file name of a generic icon that represents the MIME type.

This should be used if the icon returned by iconName() cannot be found on the system. It is used for categories of similar types (like spreadsheets or archives) that can use a common icon. The freedesktop.org Icon Naming Specification lists a set of such icon names.

The icon name can be given to QIcon::fromTheme() in order to load the icon.

QStringList QMimeType::globPatterns() const

Returns the list of glob matching patterns.

QString QMimeType::iconName() const

Returns the file name of an icon image that represents the MIME type.

The icon name can be given to QIcon::fromTheme() in order to load the icon.

bool QMimeType::inherits(const QString & mimeTypeName) const

Returns true if this mimetype is mimeTypeName, or inherits mimeTypeName (see parentMimeTypes()), or mimeTypeName is an alias for this mimetype.

bool QMimeType::isDefault() const

Returns true if this MIME type is the default MIME type which applies to all files: application/octet-stream.

bool QMimeType::isValid() const

Returns true if the QMimeType object contains valid data, otherwise returns false. A valid MIME type has a non-empty name(). The invalid MIME type is the default-constructed QMimeType.

QString QMimeType::name() const

Returns the name of the MIME type.

QStringList QMimeType::parentMimeTypes() const

A type is a subclass of another type if any instance of the first type is also an instance of the second. For example, all image/svg+xml files are also text/xml, text/plain and application/octet-stream files. Subclassing is about the format, rather than the category of the data (for example, there is no 'generic spreadsheet' class that all spreadsheets inherit from). Conversely, the parent mimetype of image/svg+xml is text/xml.

A mimetype can have multiple parents. For instance application/x-perl has two parents: application/x-executable and text/plain. This makes it possible to both execute perl scripts, and to open them in text editors.

QString QMimeType::preferredSuffix() const

Returns the preferred suffix for the MIME type.

QStringList QMimeType::suffixes() const

Returns the known suffixes for the MIME type.

void QMimeType::swap(QMimeType & other)

Swaps QMimeType other with this QMimeType object.

This operation is very fast and never fails.

The swap() method helps with the implementation of assignment operators in an exception-safe way. For more information consult More C++ Idioms - Copy-and-swap.

bool QMimeType::operator!=(const QMimeType & other) const

Returns true if other does not equal this QMimeType object, otherwise returns false.

QMimeType & QMimeType::operator=(const QMimeType & other)

Assigns the data of other to this QMimeType object, and returns a reference to this object.

bool QMimeType::operator==(const QMimeType & other) const

Returns true if other equals this QMimeType object, otherwise returns false.

Cette page est une traduction d'une page de la documentation de Qt, écrite par Nokia Corporation and/or its subsidiary(-ies). Les éventuels problèmes résultant d'une mauvaise traduction ne sont pas imputables à Nokia. Qt 5.0-snapshot
Copyright © 2012 Developpez LLC. Tous droits réservés Developpez LLC. Aucune reproduction, même partielle, ne peut être faite de ce site et de l'ensemble de son contenu : textes, documents et images sans l'autorisation expresse de Developpez LLC. Sinon, vous encourez selon la loi jusqu'à 3 ans de prison et jusqu'à 300 000 E de dommages et intérêts. Cette page est déposée à la SACD.
Vous avez déniché une erreur ? Un bug ? Une redirection cassée ? Ou tout autre problème, quel qu'il soit ? Ou bien vous désirez participer à ce projet de traduction ? N'hésitez pas à nous contacter ou par MP !
 
 
 
 
Partenaires

Hébergement Web