Menu
  • HOME
  • TAGS

Error: forward declaration of ‘class SActionPrivate’ when using PIMPL

c++,qt,cmake,pimpl-idiom,moc

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" ...

Qt metaObject->indexOfMethod always return -1

c++,qt,qtcore,moc,qmetaobject

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...

Qt/C++11 throw, final override in method prototype

c++,qt,c++11,moc

It seems that exception specifications are deprecated in C++11 (but the noexcept specifier is significant). So just remove the throw(std::runtime_error)...

How to add a 'non-built' file to a project with C-Make

qt,cmake,moc

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...

Difference between emit and emit()

c++,qt,qtcore,qt-signals,moc

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?

c++,qt,qtcore,qt-signals,moc

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...

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

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,...

Undefined reference to in Constructor with QNetworkAccessManager derived class

c++,qt,qtcore,qtnetwork,moc

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,...

Demystifying this command line build sequence

android,c++,qt,qt5,moc

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...