I have a console based app code is like this,
#include <QApplication>
#include <iostream>
using namespace std;
{
Q_OBJECT
public:
void callme()
{
cout <<"callme()";
emit taskCompleted();
}
signals:
void taskCompleted();
};
#include "main.moc"
int main(int argc, char *argv[])
{
dummy me;
QObject::connect (&me,
SIGNAL(taskCompleted
()),
&myapp,
SLOT(quit
()));
me.callme();
return myapp.exec();
}
#include <QApplication>
#include <iostream>
using namespace std;
class dummy : public QObject
{
Q_OBJECT
public:
void callme()
{
cout <<"callme()";
emit taskCompleted();
}
signals:
void taskCompleted();
};
#include "main.moc"
int main(int argc, char *argv[])
{
QApplication myapp(argc,argv);
dummy me;
QObject::connect (&me,SIGNAL(taskCompleted()),&myapp,SLOT(quit()));
me.callme();
return myapp.exec();
}
To copy to clipboard, switch view to plain text mode
It never makes clean exit, it just hangs. once taskCompleted is emitted it should call quit and make clean exit. Is it expected or am I wrong here ?? I have to press ctrl+c to exit.
thanks,
Raajesh
Bookmarks