#ifndef MAINWINDOW_H#define MAINWINDOW_H#include <QMainWindow>#include <QDebug>#include <QTimer>class MainWindow : public QMainWindow{ Q_OBJECTpublic: int i; MainWindow(QWidget *parent = 0); ~MainWindow(); bool flt,t1; QTimer *tm;public slots: void mytms() { flt=false; }};#endif // MAINWINDOW_H//====================#include <QtWidgets>#include "mainwindow.h"MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent){ tm=new QTimer(); tm->setSingleShot(true); connect(tm,SIGNAL(timeout()),this,SLOT(mytms())); flt=true; qDebug()<<"aa"; tm->start(15); t1=tm->isActive(); while(flt) { t1=tm->isActive(); } qDebug()<<"bb";}MainWindow::~MainWindow(){}//=======================#include "mainwindow.h"#include <QApplication>int main(int argc, char *argv[]){ QApplication a(argc, argv); MainWindow w; w.show(); return a.exec();}//==============QT += core guigreaterThan(QT_MAJOR_VERSION, 4): QT += widgetsTARGET = qtimer_tstTEMPLATE = appSOURCES += main.cpp\ mainwindow.cppHEADERS += mainwindow.h