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

New in version 5.0.
Synopsis¶
Functions¶
def
__eq__
(other)def
__ne__
(other)def
aliases
()def
allAncestors
()def
comment
()def
filterString
()def
genericIconName
()def
globPatterns
()def
iconName
()def
inherits
(mimeTypeName)def
isDefault
()def
isValid
()def
name
()def
parentMimeTypes
()def
preferredSuffix
()def
suffixes
()def
swap
(other)
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.
See also
-
class
PySide6.QtCore.
QMimeType
¶ PySide6.QtCore.QMimeType(other)
- Parameters
other –
PySide6.QtCore.QMimeType
Constructs this QMimeType
object initialized with default property values that indicate an invalid MIME type.
-
PySide6.QtCore.QMimeType.
aliases
()¶ - Return type
list of strings
-
PySide6.QtCore.QMimeType.
allAncestors
()¶ - Return type
list of strings
-
PySide6.QtCore.QMimeType.
comment
()¶ - Return type
str
-
PySide6.QtCore.QMimeType.
filterString
()¶ - Return type
str
-
PySide6.QtCore.QMimeType.
genericIconName
()¶ - Return type
str
-
PySide6.QtCore.QMimeType.
globPatterns
()¶ - Return type
list of strings
-
PySide6.QtCore.QMimeType.
iconName
()¶ - Return type
str
-
PySide6.QtCore.QMimeType.
inherits
(mimeTypeName)¶ - Parameters
mimeTypeName – str
- 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.
-
PySide6.QtCore.QMimeType.
isDefault
()¶ - Return type
bool
-
PySide6.QtCore.QMimeType.
isValid
()¶ - Return type
bool
-
PySide6.QtCore.QMimeType.
name
()¶ - Return type
str
-
PySide6.QtCore.QMimeType.
__ne__
(other)¶ - Parameters
other –
PySide6.QtCore.QMimeType
- Return type
bool
Returns true
if other
does not equal this QMimeType
object, otherwise returns false
.
-
PySide6.QtCore.QMimeType.
__eq__
(other)¶ - Parameters
other –
PySide6.QtCore.QMimeType
- 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.
-
PySide6.QtCore.QMimeType.
parentMimeTypes
()¶ - Return type
list of strings
-
PySide6.QtCore.QMimeType.
preferredSuffix
()¶ - Return type
str
-
PySide6.QtCore.QMimeType.
suffixes
()¶ - Return type
list of strings
-
PySide6.QtCore.QMimeType.
swap
(other)¶ - Parameters
other –
PySide6.QtCore.QMimeType
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 .
© 2021 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.