QMimeType

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

Inheritance diagram of PySide2.QtCore.QMimeType

New in version 5.0.

Synopsis

Functions

Detailed Description

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.

class QMimeType

QMimeType(other)

param other

QMimeType

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

PySide2.QtCore.QMimeType.aliases()
Return type

list of strings

PySide2.QtCore.QMimeType.allAncestors()
Return type

list of strings

PySide2.QtCore.QMimeType.comment()
Return type

unicode

PySide2.QtCore.QMimeType.filterString()
Return type

unicode

PySide2.QtCore.QMimeType.genericIconName()
Return type

unicode

PySide2.QtCore.QMimeType.globPatterns()
Return type

list of strings

PySide2.QtCore.QMimeType.iconName()
Return type

unicode

PySide2.QtCore.QMimeType.inherits(mimeTypeName)
Parameters

mimeTypeName – unicode

Return type

bool

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

This method has been made invokable from QML since 5.10.

PySide2.QtCore.QMimeType.isDefault()
Return type

bool

PySide2.QtCore.QMimeType.isValid()
Return type

bool

PySide2.QtCore.QMimeType.name()
Return type

unicode

PySide2.QtCore.QMimeType.__ne__(other)
Parameters

otherQMimeType

Return type

bool

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

PySide2.QtCore.QMimeType.__eq__(other)
Parameters

otherQMimeType

Return type

bool

Returns true if other equals this QMimeType object, otherwise returns false . The name is the unique identifier for a mimetype, so two mimetypes with the same name, are equal.

PySide2.QtCore.QMimeType.parentMimeTypes()
Return type

list of strings

PySide2.QtCore.QMimeType.preferredSuffix()
Return type

unicode

PySide2.QtCore.QMimeType.suffixes()
Return type

list of strings

PySide2.QtCore.QMimeType.swap(other)
Parameters

otherQMimeType

Swaps QMimeType other with this QMimeType object.

This operation is very fast and never fails.

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