How to make signals and slots working in a console application? (Event loop not working)
-
Hello,
I have a console application and my main looks basically like that:
#include "myclass" #include <QCoreApplication> int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); MyClass myClass; myClass.process(); return a.exec();
"MyClass" is not derived from Qt but in this class another class is instantiated and this is derived from QObject, has the QObject-Marcro and needs a working signal-slot-machanism.
What is necessary that this works?
Thank you very much!
-
@robro said in How to make signals and slots working in a console application? (Event loop not working):
What is necessary that this works?
Nothing in particular, only that
MyClass
doesn't block the event loop, the typical case is running awhile(true)
-
Thanks,
I do not understand this.
If I would have a mainwindow, where would this loop be then?Where should I integrate this loop?
Where and how could the event loop pause my code execution and execute the signal and slot things?
Wouldn't I need different threads for that?