Would appreciate someone's help with this newbie question.
With Qt 4.7, 4.8 and 5.0, my console application hangs when I run it. I'm expecting it to run to completion.
// from app.h
{
Q_OBJECT
public:
void exec()
{
emit finished();
}
signals:
void finished();
public slots:
};
// from app.cpp
{
connect(this, SIGNAL(finished()), app, SLOT(quit()));
}
// from main.cpp
int main(int argc, char *argv[])
{
App app(&a);
app.exec();
return a.exec();
}
// from app.h
class App : public QObject
{
Q_OBJECT
public:
explicit App(QCoreApplication *app, QObject *parent = 0);
void exec()
{
emit finished();
}
signals:
void finished();
public slots:
};
// from app.cpp
App::App(QCoreApplication *app, QObject *parent) :
QObject(parent)
{
connect(this, SIGNAL(finished()), app, SLOT(quit()));
}
// from main.cpp
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
App app(&a);
app.exec();
return a.exec();
}
To copy to clipboard, switch view to plain text mode
Why doesn't this app just immediately terminate and return control to the command line?
Bookmarks