app.setQuitOnLastWindowClosed(true);
#include <QtGui/QMessageBox>#include <QtGui/QMainWindow>#include "ui_test2.h"class test2 : public QMainWindow{ Q_OBJECTpublic: test2(QWidget *parent = 0, Qt::WFlags flags = 0) :QMainWindow(parent, flags) { ui.setupUi(this); } ~test2(){};private: Ui::test2Class ui;private slots: void getNewItems() { QMessageBox::warning(0,"",""); }};
#include <QtGui/QApplication>#include <QtCore/QTimer>#include "test2.h"int main(int argc, char *argv[]){ QApplication a(argc, argv); test2 w; w.show(); QTimer *timer = new QTimer(&w); a.connect(timer, SIGNAL(timeout()), &w, SLOT(getNewItems())); timer->start(10000); w.hide(); //w.getNewItems(); a.connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit())); return a.exec();}