Questions tagged [moc]

MOC is Qt's Meta Object Compiler. It transforms certain Qt-specific macros into the C++ code and meta information necessary for Qt's signal and slots, RTTI, and the dynamic property system.

The meta-object system is based on three things:

  1. The QObject class provides a base class for objects that can take advantage of the meta-object system.
  2. The Q_OBJECT macro inside the private section of the class declaration is used to enable meta-object features, such as dynamic properties, signals, and slots.
  3. The Meta-Object Compiler (moc) supplies each QObject subclass with the necessary code to implement meta-object features.
216 questions
8
votes
1 answer

Qt MOC multiple files in parallel with MSBuild

Good morning! I know there is already this question here: Qt Moc'ing multiple files in parallel under msbuild but I would not show up this old question. I work under Visual Studio 2010 and I've got to speed up the compilation time of my app. I use…
CloudCompany
  • 357
  • 3
  • 15
8
votes
3 answers

Difference between emit and emit()

In Qt, both of them are valid, and behave the same: emit someSignal(value); vs emit(someSignal(value)); Is there any difference?
otisonoza
  • 1,334
  • 2
  • 14
  • 32
8
votes
2 answers

C++ using signal slots for QML

I have a small class that is not working properly, and I can't get what is wrong with it. The compiler gives the message: main.cpp: error: undefined reference to 'CDetails::CDetails()' This is the snapshot from the code: //main.cpp #include…
Judith
  • 271
  • 2
  • 9
8
votes
2 answers

QObject: Missing vtable link error

I know the question have been asked tons of times but I can't find the solution here nor in google. Here's my header file #ifndef MAINCONTROLLER_H #define MAINCONTROLLER_H #include #include #include #include…
Thomas Ayoub
  • 29,063
  • 15
  • 95
  • 142
7
votes
1 answer

qt moc error:usr/include/c++/10/bits/fs_fwd.:39: Parse error at "std"

my configuration is: ubuntu 21.04 gcc 11 qt 5.15.2 and error message like this: AutoMoc subprocess error ------------------------ The moc process failed to compile "SRC:/src/Layers/ViewLayer/Process/NearFieldProcessUtil.h" into …
Alex Luya
  • 9,412
  • 15
  • 59
  • 91
6
votes
3 answers

What's causing this QT 4.7.3 error?

I have a program which compiles just fine in OpenSuse 11.2 with QT version 4.5. However, when I compiled the same program using OpenSuse 11.4 with QT 4.7.3, I'm getting this error message: "This file was generated using the moc from 4.7.3. It…
Owen
  • 4,063
  • 17
  • 58
  • 78
6
votes
6 answers

Qt using CMake: ui_mainwindow.h: No such file or directory

I use Qt with CMake because CMake integrates with my team's work easier than my own. I have frequently encountered an error along the lines of ui_*.h: No such file or directory Usually when my project already has a ui_*.h file to start with it…
Daniel Arnett
  • 493
  • 2
  • 8
  • 18
6
votes
1 answer

Why QObject needs to be the first in case of multiple inheritance

According to http://qt-project.org/doc/qt-4.8/moc.html#multiple-inheritance-requires-qobject-to-be-first the QObject must be the first in the base classes when using multiple inheritance. Is this because of some limitation in the moc tool or C++…
Ferenc Deak
  • 34,348
  • 17
  • 99
  • 167
5
votes
3 answers

Why my project doesn't link if there are Q_OBJECT macros in .cpp files?

This code compiles, links and works as intended: #include #include #include "File_List_Model.h" int main(int c,char**v) { QApplication app(c,v); QStringList list; list << "a" << "b" << "c"; …
smallB
  • 16,662
  • 33
  • 107
  • 151
5
votes
1 answer

CMake + Qt : define the moc/ui output directory

I'm currently transferring a project built with qmake to CMake. In the version with qmake, in the .pri file, there was MOC_DIR = .moc/$${PLATFORM_NAME} that permitted to produce the MOC temporary files in a given directory, keeping the sources…
Vincent
  • 57,703
  • 61
  • 205
  • 388
5
votes
0 answers

CMake AUTOMOC is slow

I have a QT project with that is built with CMake. One of the targets have 142 files that need to have moc. When I use qt5_wrap_cpp on source files and build it the process gets finished in around 15 seconds: set(CMAKE_AUTOMOC…
Teivaz
  • 5,462
  • 4
  • 37
  • 75
5
votes
2 answers

Macro expansion in moc

I'd like to store some class info using Q_CLASSINFO macro. However I would like to wrap it in my own macro, for example: #define DB_TABLE( TABLE ) \ Q_CLASSINFO( "db_table", #TABLE ) #define DB_FIELD( PROPERTY, COLUMN ) \ Q_CLASSINFO(…
zarzych
  • 981
  • 1
  • 11
  • 18
5
votes
1 answer

CMake AUTOMOC with files on different folders

I have a simple CMake project: proj (project folder) ├── a.h ├── a.cpp └── CMakeLists.txt CMakeLists.txt: cmake_minimum_required(VERSION 3.2) set(CMAKE_VERBOSE_MAKEFILE ON) set(CMAKE_AUTOMOC ON) project(proj) set( proj_SOURCE …
Mac
  • 3,397
  • 3
  • 33
  • 58
5
votes
3 answers

Using a macro to create QObject derived classes

I'm trying to simplify (i.e. get rid of loads of boilerplate code) the creation of QObject wrapper classes that forward property access of other QObject derived classes. To start small, I'm just trying it with one property: // Sy_test.h - The…
cmannett85
  • 21,725
  • 8
  • 76
  • 119
5
votes
3 answers

Could I have copy constructor for subclass of QObject?

Here we can read that no copy construct and copy assignment operator evaluable. But here we can read that qRegisterMetaType and Q_DECLARE_METATYPE have to have public default constructor, public copy constructor and public destructor. The question…
VALOD9
  • 566
  • 2
  • 6
  • 22
1
2
3
14 15