void MainWindow::doThat()
{
// private: int m_numDestroyed;
m_numDestroyed = 0;
for(QTimer*& singleTim : {timerA ,timerB ,timerC }){
singleTim = new QTimer(this);
singleTim ->setInterval(100);
singleTim->setSingleShot(true);
}
const auto checkDestroyed=[=]()->void{
if(++m_numDestroyed>1){
delete numDestroyed;
timerC->start();
};
connect(timerA,&QTimer::timeout,this,[=]()->void{
qDebug("slot A");
checkDestroyed();
}
});
connect(timerB,&QTimer::timeout,this,[=]()->void{
qDebug("slot B");
checkDestroyed();
}
});
connect(timerC,&QTimer::timeout,this,[=]()->void{
qDebug("slot C");
}
});
connect(timerA,&QTimer::timeout,timerA,&QTimer::deleteLater);
connect(timerB,&QTimer::timeout,timerB,&QTimer::deleteLater);
timerA->start();
timerB->start();
}