PDA

View Full Version : Connecting Button with Quit-Signal



moatilliatta
11th October 2010, 16:01
Hello everyone,

i have a button who should work like an exit button that appears at the end of my program. I used this line of code to realize it but it does not work at all.


connect(endBtn, SIGNAL(clicked()), this, SLOT(quit()));

Is this because i do call the quit on "this" and not in the main.cpp? If yes, how do i connect the endBtn properly?

Thank you very much.
greetings
moatilliatta

Zlatomir
11th October 2010, 16:19
You can use qApp macro to get a pointer to the QApplication instance,like this:

connect(endBtn, SIGNAL(clicked()), qApp, SLOT(quit()));