Right, you have two issues in here: Missing includepath for the cmake binary directory where moc is generated ${CMAKE_CURRENT_BINARY_DIR} You need to include the moc file at the end of your corresponding source file #include "moc_saction.cpp" ...
Apart from the two compiler errors, your approach seems to be correct. I assume that you had some changes that required to rerun moc, but you have not actually done so. This is the working code for me. main.cpp #include <QMetaObject> #include <QDebug> #include <QString> class Foo : public QObject...
It seems that exception specifications are deprecated in C++11 (but the noexcept specifier is significant). So just remove the throw(std::runtime_error)...
If the file is generated by something CMake understands (that is, by a custom command in the same CMakeList), you can just list it and CMake will pick up the dependency by itself. For other cases, there is a source file property GENERATED which you can set on the source...
Is there any difference? There is no difference other than the external bracket being needless, so programmers will prefer that, and it is also more conventionally used in Qt projects out there. The reason for the no difference is due to this: # define emit You can see the...
Are signals and slots syntactic sugar or there is more to them? The question that I have is that, are signals and slots simply syntactic sugar for event listeners/handlers No, the mean reason for their existence is decoupling of the emission and handling. or what happens in the background...
c++,qt,inheritance,qobject,moc
Assume that we have a class Test declared as: class Test : public Foo, public QObject { Q_OBJECT [..] }; If you take a look at the moc_test.cpp file that the moc tool has generated, you will see something like: [..] const QMetaObject Command::staticMetaObject = { { &Foo::staticMetaObject, qt_meta_stringdata_Command, qt_meta_data_Command,...
There are so many issues with your short code, but I will focus below on the most central part of those. Include the moc file The general practice is this: void SillyRequest :: replyFinished(QNetworkReply *reply) { collectedData = reply->readAll(); } #include "main.moc" // This is the addition int main(int argc,...
In short, you have three different processes running for various inputs and outputs. These namely are: compiler to compile source code into object files. meta object compiler to generate source code. linker to link all the object files together into a binary, in this case shared librarry. Step 1 The...