PySide6.QtCore.QMimeType¶
- class QMimeType¶
- The - QMimeTypeclass describes types of file or data, represented by a MIME type string. More…- Synopsis¶- Properties¶- aliasesᅟ- The list of aliases of this mimetype
- allAncestorsᅟ- The names of direct and indirect parent MIME types
- commentᅟ- The description of the MIME type to be displayed on user interfaces
- filterStringᅟ- Filter string usable for a file dialog
- genericIconNameᅟ- The file name of a generic icon that represents the MIME type
- globPatternsᅟ- The list of glob matching patterns
- iconNameᅟ- The file name of an icon image that represents the MIME type
- isDefaultᅟ- True if this MIME type is the default MIME type which applies to all files: application/octet-stream
- nameᅟ- The name of the MIME type
- parentMimeTypesᅟ- The names of parent MIME types
- preferredSuffixᅟ- The preferred suffix for the MIME type
- suffixesᅟ- The known suffixes for the MIME type
- validᅟ- True if the QMimeType object contains valid data, false otherwise
 - Methods¶- def - __init__()
- def - aliases()
- def - allAncestors()
- def - comment()
- def - filterString()
- def - globPatterns()
- def - iconName()
- def - inherits()
- def - isDefault()
- def - isValid()
- def - name()
- def - __ne__()
- def - __eq__()
- def - suffixes()
- def - swap()
 - Note - This documentation may contain snippets that were automatically translated from C++ to Python. We always welcome contributions to the snippet translation. If you see an issue with the translation, you can also let us know by creating a ticket on https:/bugreports.qt.io/projects/PYSIDE - 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 - iconfor the file, or even the descriptive- commentin 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 - QMimeDatabaseMIME Type Browser- Note - Properties can be used directly when - from __feature__ import true_propertyis used or via accessor functions otherwise.- property aliasesᅟ: list of strings¶
 - This property holds the list of aliases of this mimetype. - For instance, for text/csv, the returned list would be: text/x-csv, text/x-comma-separated-values. - Note that all - QMimeTypeinstances refer to proper mimetypes, never to aliases directly.- The order of the aliases in the list is undefined. - While this property was introduced in 5.10, the corresponding accessor method has always been there. - Access functions:
 - property allAncestorsᅟ: list of strings¶
 - This property holds the names of direct and indirect parent MIME types. - 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). - While this property was introduced in 5.10, the corresponding accessor method has always been there. - Access functions:
 - property commentᅟ: str¶
 - This property holds the description of the MIME type to be displayed on user interfaces. - The default language (QLocale(). - name()) is used to select the appropriate translation.- While this property was introduced in 5.10, the corresponding accessor method has always been there. - Access functions:
 - property filterStringᅟ: str¶
 - This property holds a filter string usable for a file dialog. - While this property was introduced in 5.10, the corresponding accessor method has always been there. - Access functions:
 - property genericIconNameᅟ: str¶
 - This property holds 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. - While this property was introduced in 5.10, the corresponding accessor method has always been there. - Access functions:
 - property globPatternsᅟ: list of strings¶
 - This property holds the list of glob matching patterns. - While this property was introduced in 5.10, the corresponding accessor method has always been there. - Access functions:
 - property iconNameᅟ: str¶
 - This property holds 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. - While this property was introduced in 5.10, the corresponding accessor method has always been there. - Access functions:
 - property isDefaultᅟ: bool¶
 - This property holds - trueif this MIME type is the default MIME type which applies to all files: application/octet-stream..- While this property was introduced in 5.10, the corresponding accessor method has always been there. - Access functions:
 - property nameᅟ: str¶
 - This property holds the name of the MIME type. - While this property was introduced in 5.10, the corresponding accessor method has always been there. - Access functions:
 - property parentMimeTypesᅟ: list of strings¶
 - This property holds the names of parent MIME types. - 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. - While this property was introduced in 5.10, the corresponding accessor method has always been there. - Access functions:
 - property preferredSuffixᅟ: str¶
 - This property holds the preferred suffix for the MIME type. - No leading dot is included, so for instance this would return “pdf” for application/pdf. The return value can be empty, for mime types which do not have any suffixes associated. - While this property was introduced in 5.10, the corresponding accessor method has always been there. - Access functions:
 - property suffixesᅟ: list of strings¶
 - This property holds the known suffixes for the MIME type. - No leading dot is included, so for instance this would return “jpg”, “jpeg” for image/jpeg. - While this property was introduced in 5.10, the corresponding accessor method has always been there. - Access functions:
 - property validᅟ: bool¶
 - This property holds - trueif the- QMimeTypeobject contains valid data,- falseotherwise.- A valid MIME type has a non-empty - name(). The invalid MIME type is the default-constructed- QMimeType.- While this property was introduced in 5.10, the corresponding accessor method has always been there. - Access functions:
 - __init__()¶
 - Constructs this - QMimeTypeobject initialized with default property values that indicate an invalid MIME type.- __init__(other)
- Parameters:
- other – - QMimeType
 
 - Constructs this - QMimeTypeobject as a copy of- other.- aliases()¶
- Return type:
- list of strings 
 
 - Getter of property - aliasesᅟ.- allAncestors()¶
- Return type:
- list of strings 
 
 - Getter of property - allAncestorsᅟ.- comment()¶
- Return type:
- str 
 
 - Getter of property - commentᅟ.- filterString()¶
- Return type:
- str 
 
 - Getter of property - filterStringᅟ.- genericIconName()¶
- Return type:
- str 
 
 - Getter of property - genericIconNameᅟ.- globPatterns()¶
- Return type:
- list of strings 
 
 - Getter of property - globPatternsᅟ.- iconName()¶
- Return type:
- str 
 
 - Getter of property - iconNameᅟ.- inherits(mimeTypeName)¶
- Parameters:
- mimeTypeName – str 
- Return type:
- bool 
 
 - Returns - trueif this mimetype is- mimeTypeName, or inherits- mimeTypeName(see- parentMimeTypes()), or- mimeTypeNameis an alias for this mimetype.- This method has been made invokable from QML since 5.10. - isDefault()¶
- Return type:
- bool 
 
 - Getter of property - isDefaultᅟ.- isValid()¶
- Return type:
- bool 
 
 - Getter of property - validᅟ.- name()¶
- Return type:
- str 
 
 - Getter of property - nameᅟ.- Returns - trueif- QMimeType- lhsis not equal to- QMimeType- rhs, otherwise returns- false.- Returns - trueif- lhsequals to the- rhs- QMimeTypeobject, otherwise returns- false. The name is the unique identifier for a mimetype, so two mimetypes with the same name, are equal.- parentMimeTypes()¶
- Return type:
- list of strings 
 
 - Getter of property - parentMimeTypesᅟ.- preferredSuffix()¶
- Return type:
- str 
 
 - Getter of property - preferredSuffixᅟ.- suffixes()¶
- Return type:
- list of strings 
 
 - Getter of property - suffixesᅟ.- Swaps this mime type with - other. 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 .