2 votes
MOC File - What is a .moc file and how do I open it?
Learn about .MOC files and view a list of programs that open them.
Languages
Overview
What is a MOC file? A MOC file is a source code file produced by the Qt development toolkit's Meta-Object Compiler. It contains meta-object code written in C++. MOC files are referenced in Qt .CPP files, to allow Qt's qmake compiler to correctly compile applications that include Q_OBJECT classes in a CPP file.
More Information Qt is a C++ development toolkit that developers can use to create graphical user interfaces (GUIs) and cross-platform applications that run on both desktop and mobile environments. The toolkit includes a several specialized features, such as the meta-object system. The Qt meta-object system provides a signals and slots mechanism for inter-object communication, run-time type information, and the toolkit's dynamic property system. Developers can label C++ header objects as meta-objects using the Q_OBJECT class and macro. Then, when the developer compiles their program, Qt's Meta-Object Compiler produces a C++ source code file that contains the meta-object code for these classes. When a developer compiles a program that includes a Q_OBJECT declaration in a CPP file, they must structure their code such that the Qt Meta-Object Compiler will transform the declaration into a MOC file before Qt compiles the CPP file. Otherwise, the developer's program will not compile correctly. The developer must also reference the MOC file at the end of their CPP file (e.g. #include example.moc ), to ensure it is included as Qt compiles the CPP file.
Document Icon
Breadcrumbs
Previous / Next
In-Depth
.MOC File Extension
Qt Meta-Object Compiler File
| Developer | Qt Group |
| Popularity |
2.0 | 2 Votes |
What is a MOC file?
A MOC file is a source code file produced by the Qt development toolkit's Meta-Object Compiler. It contains meta-object code written in C++. MOC files are referenced in Qt .CPP files, to allow Qt's qmake compiler to correctly compile applications that include Q_OBJECT classes in a CPP file.
More Information
Qt is a C++ development toolkit that developers can use to create graphical user interfaces (GUIs) and cross-platform applications that run on both desktop and mobile environments. The toolkit includes a several specialized features, such as the meta-object system.
The Qt meta-object system provides a signals and slots mechanism for inter-object communication, run-time type information, and the toolkit's dynamic property system. Developers can label C++ header objects as meta-objects using the Q_OBJECT class and macro. Then, when the developer compiles their program, Qt's Meta-Object Compiler produces a C++ source code file that contains the meta-object code for these classes.
When a developer compiles a program that includes a Q_OBJECT declaration in a CPP file, they must structure their code such that the Qt Meta-Object Compiler will transform the declaration into a MOC file before Qt compiles the CPP file. Otherwise, the developer's program will not compile correctly. The developer must also reference the MOC file at the end of their CPP file (e.g. #include example.moc ), to ensure it is included as Qt compiles the CPP file.
How to open a MOC file
Because MOC files are C++ source code files, you can open and edit them in any text or source code editor. Source code editors, such as Microsoft Visual Studio Code (cross-platform) and GitHub Atom (cross-platform), provide helpful features that make viewing and editing MOC files easier.
Open over 400 file formats with File Viewer Plus . Free Download
Programs that open or reference MOC files
Sort
Pricing
Program Name
Platform
Reset
X
Windows
Qt SDK
Free +
Microsoft Visual Studio Code
Free
GitHub Atom
—
Discontinued
Free
GNU Emacs
Free
Any text editor
Mac
Qt SDK
Free +
Microsoft Visual Studio Code
Free
GitHub Atom
—
Discontinued
Free
GNU Emacs
Free
Any text editor
Linux
Qt SDK
Free +
Microsoft Visual Studio Code
Free
GitHub Atom
—
Discontinued
Free
GNU Emacs
Free
Any text editor
Category: Developer Files
Updated: December 29, 2021