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
0
votes
1 answer

Qt moc file is not expanding a macro defined before #include "foo.h"

Given the following code: // foo.h #ifdef BIG_DATA_MACRO #warning "TEXT ADDED" #define TEXT_HANDLING_MACRO \ static const char * TEXT[]; \ static const char * getText( int _enum ) { \ return TEXT[_enum]; \ …
Oli
  • 1,313
  • 14
  • 31
0
votes
2 answers

How to use the pimpl idiom with Qt and subclasses of QObject

I would like to know the easiest way to implement the pimpl idiom in Qt objects. What I want to have is something like this: pimpl.h: class B; class A: public QObject { B *b; } pimpl.cxx: class B: public QObject { } Now, as is obvious, Qt…
0
votes
0 answers

Qt Signal/Slot configuration

I have a matter with signal/slots in Qt 5.6.0 When I try to compile, I get the following error: I googled it and I found out when I use qmake(which is the case I believe) then I have to do some moc tricking, however as a compelte Qt beginner I did…
Bachey
  • 35
  • 4
0
votes
1 answer

Passing arguments from qmake to moc per header

I'd like to be able to pass arguments to the moc compiler from a qmake project, but only for specific files. Example, in some .pro file: HEADER += foo.h \ bar.h \ baz.h I'd like to pass -ffoo_extra.h to foo.h, -fbar_extra.h to…
Scott
  • 23
  • 5
0
votes
1 answer

Qt moc error using CMake

I am trying to write an OpenCV application creating the GUI with Qt and generating the makefiles using CMake. The problem that I have is that when I try to execute the make command, I get the error: This file was generated using the moc from 5.2.1.…
Mr Squid
  • 1,196
  • 16
  • 34
0
votes
1 answer

Dynamically use QGLWidget or QOpenGLWidget depending on Qt version

My code is supposed to compile and run on platforms before and after Qt 5.4 where QOpenGLWidget was introduced, superseding QGLWidget. I thought I could write code like this to support both: #if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0) # define…
josch
  • 6,716
  • 3
  • 41
  • 49
0
votes
0 answers

cmake qt automoc - getting automoc'ed files as variable

Is it possible to get the automoc'ed files (Qt moc)? That would be great because i could put it on a source_group. I'm using cmake 3.4.1 Thanks in advance Tonka
Michael Aigner
  • 4,820
  • 4
  • 21
  • 33
0
votes
0 answers

Qt moc issue (moc.exe: command not found) while building Qwt with Qt 5 in Windows

Building Qwt with Qt 5 fails (with Qt 4 works) in Windows 7 64 bits. I tried via Qt Creator and via CLI but both ends in: 12:51:08: Running steps for project qwt... 12:51:08: Starting: "C:\Qt\Qt5.3.2\5.3\mingw482_32\bin\qmake.exe"…
KcFnMi
  • 5,516
  • 10
  • 62
  • 136
0
votes
1 answer

Qt5.5.1: How to create QT application that uses frameworks generated from qt-everywhere-opensource-src

I should have asked this question before asking this I am creating a QT app (on MAC) that should use frameworks compiled from qt-everywhere-opensource-src-5.5.1.tgz and not the one that comes with qt-opensource-mac-x64-clang-5.5.0.dmg. I use QT…
JamesWebbTelescopeAlien
  • 3,547
  • 2
  • 30
  • 51
0
votes
0 answers

Wrong qt moc.exe path

I'm trying to switch from Qt4.8.6 to Qt5. I'm using MSVS2010 for my old code in c++/Qt. I changed all the paths and made other changes for Qt migration. On recompiling the code I noticed the moc.exe path is still pointing to older version of Qt i.e.…
gaj
  • 317
  • 6
  • 20
0
votes
0 answers

Auto moc file generation in Makefile

So i have a pretty standard make file #!/bin/bash CXX=g++ CXXFLAGS= -g -Wall SOURCES=$(wildcard src/*.cpp) OBJECTS=$(addprefix obj/,$(notdir $(SOURCES:.cpp=.o))) INCLUDES=-I/usr/include/ -I.…
SketchyManDan
  • 176
  • 1
  • 10
0
votes
1 answer

How to create moc files in Visual Studio 2013?

Currently I am using Visual Studio 2013 on Windows 8.1. I have installed the QT5 add-in with version QT 4.8.3(Because I couldn't install QT4 add-in). When running my project, almost moc files are generated. But my class didn't generate moc files.…
0
votes
0 answers

Exclude moc files from solution generated by Cmake

I create a project with cmake for Visual Studio 10, using Qt5.4 library. Cmake generates moc files for Qt and integrates these files into my solution. I would like to find a way to prevent Cmake to integrate the moc files into the solution, coz then…
Quentin Tealrod
  • 309
  • 3
  • 14
0
votes
1 answer

New QObject::connect syntax doesn't work

I'm using the new syntax for QObject::connect to connect a signal to a slot: connect(m_pNetworkReply, &QNetworkReply::error, this, &MyClass::onError); but I'm getting this weird error and I have no idea…
Jacob Krieg
  • 2,834
  • 15
  • 68
  • 140
0
votes
1 answer

No moc file is generated by make

I try to compile a qt cpp file but no moc is generated for Q_OBJECT objects. I am using Maya's distribution of qt. My makefile.qt file looks like this and I am compiling with make -f makefile.qt myPlugIn.bundle: %.mak : %.pro qtconfig $(QMAKE)…
Laurent Crivello
  • 3,809
  • 6
  • 45
  • 89