calling quit() method of QApplication
qt
Solution
The button's `clicked` signal can be connected directly to the application's `quit` slot:
QObject::connect(quitButton, SIGNAL(clicked()),
QApplication::instance(), SLOT(quit()));
Problem
if i try to use quit() method directly, it is compiling perfectly, however during runtime there comes an error saying "Object::connect: No such slot myClass::quit()." so to avoid this, is there any way? by using a method quitPicture()(defined as slot) the application is working fine. is this the only solution? ``` myClass::myClass(QWidget *parent) : QWidget(parent) { QWidget *window = new QWidget; window->setWindowTitle(QObject::tr("Class")); QPushButton *quitButton = new QPushButton("&Quit"); // QObject::connect(quitButton, SIGNAL(clicked()), this, SLOT(quit())); //showing run time error QObject::connect(quitButton, SIGNAL(clicked()), this, SLOT(quitPicture())); //working perfectly QHBoxLayout *layout = new QHBoxLayout; layout->addWidget(this); layout->addWidget(quitButton); window->setLayout(layout); window->show(); } void myClass::quitPicture() { std::cout << "calling quitPicture" << std::endl; QApplication::quit(); } ```