January 5, 2011

fifth fifth
Lab Rat
57 posts

QApplication can’t be receiver of its own signal aboutToExit?

 

I got some cleanup job before app exit, by following document, I built my own QMyApplication with a private slot cleanup() and got it connected to aboutToExit signal.

However, I found cleanup() was never called.

Then I added another class QMyApplicationHelper (definitely inherited from QObject) to receive aboutToExit instead. That worked.

I was wondering if QApplication can’t be receiver of its own signal aboutToExit.

Furthermore, I also tried an idle processing by use of a QTimer with 0 timeout, like

  1. mIdleTrigger = new QTimer(this);      // this was QMyApplication itself
  2. connect(mIdleTrigger, SIGNAL ( timeout( ) ), this, SLOT ( processIdle( ) ));
  3. mIdleTrigger->start(0);

It still never worked until I had QMyApplicationHelper be receiver of timer.

I didn’t figure out why there has to be a helper class to take over role of signal receiver.

Thx.

[EDIT: code highlighting, Volker]

4 replies

January 5, 2011

Franzk Franzk
Lab Rat
830 posts

Did you check for run-time connect errors?

 Signature 

“Horse sense is the thing a horse has which keeps it from betting on people.”—W.C. Fields

http://www.catb.org/~esr/faqs/smart-questions.html

January 5, 2011

fifth fifth
Lab Rat
57 posts

I didn’t follow you, how to check out that? I’m quite new to Qt.

Franzk wrote:
Did you check for run-time connect errors?

January 5, 2011

Franzk Franzk
Lab Rat
830 posts

Check your debug output. It might be that there is some warning about a failed connection. Also try checking the result of the connect call (it returns true on success).

 Signature 

“Horse sense is the thing a horse has which keeps it from betting on people.”—W.C. Fields

http://www.catb.org/~esr/faqs/smart-questions.html

January 5, 2011

fifth fifth
Lab Rat
57 posts


I made a stupid mistake, I forgot to declare “slots”, debugging output revealed that.
Really appreciated.

Franzk wrote:
Check your debug output. It might be that there is some warning about a failed connection. Also try checking the result of the connect call (it returns true on success).
 
  ‹‹ Parallel programming in Qt      Failed to link against QString fromStdWString & toStdWString ››

You must log in to post a reply. Not a member yet? Register here!