Editing MIME Types
Qt Creator uses the Internet media type (MIME type) of the file to determine which mode and editor to use for opening the file. For example, Qt Creator opens C++ source and header files in the C++ editor, and Qt widget based UI files (.ui) in Qt Designer.
To identify the MIME type of a file, Qt Creator uses matching by pattern and matching by contents. First, Qt Creator looks at the filename to check whether it matches the patterns specified for any MIME type. If no match is found, it checks the contents of the file for magic headers specified for the file.
The magic headers can contain the following types of values: string, host, big-endian, little-endian, and byte. Qt Creator interprets the values according to the Shared MIME-info Database specification.
Qt Creator searches for the value within a specified range in the files and takes the priority of the magic header into account. If you specify wide search ranges, openging files in Qt Creator might take a long time. Therefore, you are advised to use the recommended values for the range and priority of the magic header.
If your files do not match the predefined MIME types, you can edit the MIME types to add filename extensions and magic headers. You cannot add new MIME types, however.
To edit MIME types:
- Select Tools > Options > Environment > MIME Types.
- In MIME Type, select a MIME type.
- In Patterns, add the filename extension for the type of files that you want to identify as having this MIME type.
- Click Add to add Magic Headers.
- In the Value field, specify a text string or bytes that appear in the files.
- In the Type field, select the type of the value.
- In the Mask field, specify the number to combine the value in the file with using the AND operator before comparing it to the specified value. You can specify any numbers as masks for numerical types, whereas masks for strings must be in base 16, and start with 0x.
Note: You are recommended not to change the range and priority, because it might cause problems when opening files in Qt Creator.
- Click OK.
To revert all the changes you have made to the MIME type definitions, select Reset All.
Note: If you now select OK or Apply, you permanently lose all your own patterns and magic headers. The changes are reverted the next time you start Qt Creator.
© 2015 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.