View Full Version : close window when click on a label

29th October 2007, 07:25
I have a label in my form and it has an event clicked, ( which one i emit click() from mousePressEvent ). I need to close this window when i clicked on this label. When we click on this label, we can call a function. From that function, how can i close the window. Please help me

29th October 2007, 08:03
See QCoreApplication::quit() and QWidget::close. You can connect to one of these slots, but if you want the application to exit you should use the first signal(via the qApp pointer)

29th October 2007, 08:32
I try this, but my probs is that, from my mainwindow i create an another window and in that child window I have a label and in the click event of that label, I want to close the child window. when i try this,

connect(LblVStop, SIGNAL(clicked()), this, SLOT(quit()));
it hide that label only, not window. I need to close that window
Please help me....

29th October 2007, 08:35

connect(LblVStop, SIGNAL(clicked()), this, SLOT(close()));

This works if "this" is the window you want to close.
BTW, there's no slot called quit() in a QWidget or a QMainWindow.