Stupid question, but is this a console app?

I'm asking because this happens with console apps. It can happen with any app, but console apps tend to have the problem most often. Here is what I mean:

#include <QCoreApplication>
#include <QDebug>
#include <QTimer>

#include "consoleinput.h"

int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);
    ConsoleInput console;
    bool b = a.connect(&console, &ConsoleInput::quit, &a, 
&QCoreApplication::quit);
    qDebug() << "result of connect " << b;

    QTimer::singleShot(0, &console, &ConsoleInput::run);

    return a.exec();

}

If you do not use a QTimer to launch the console input method so it runs from within the exec() loop, i.e. replace the QTimer line with

console.run();

Your connect call will return true but the signal will never trigger the slot because execution is occurring outside of an event loop.

--

Roland Hughes, President
Logikal Solutions

http://www.theminimumyouneedtoknow.com
http://www.infiniteexposure.net
http://www.johnsmith-book.com
http://www.logikalblog.com
http://www.interestingauthors.com/blog
http://lesedi.us/

_______________________________________________
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest

Reply via email to