@Calicoder since you're a beginner, let me give you an example as complex and convoluted as possible.... 🤣
int main(int argc, char *argv[])
{
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QApplication app(argc, argv);
QTimer timerToAddtoList;
QElapsedTimer elapsedTime;
QList<qint64> listToAppendTo;
QObject::connect(&timerToAddtoList, &QTimer::timeout, [&]()->void{
listToAppendTo.append(elapsedTime.elapsed());
if(elapsedTime.elapsed() > 500){ //500 ms
timerToAddtoList.stop();
qDebug() << listToAppendTo;
QCoreApplication::quit();
}
});
elapsedTime.start();
timerToAddtoList.start(0); // 0 == 0ms == fire as soon as possible
return app.exec();
}
No seriously this contains everything you want to have, all in main. With some exotic stuff sprinkled in, to make it happen.
Could be a good "exercise" to break this up in a proper class or something similar!
If I should explain more, tell me so :D