Solved How Could I stop all timers in Qml?
-
Hello. All
I use many timers in Qml side,
I want to stop all timers in cpp file.
How can I do?xxxx.qml
Timer{
...
}xxab.qml
Timer{
...
}
...xxxx.cpp
// Want to stop all timers using in Qml -
@W-Y-Kim There are many ways for eg. finding children, setting context property or using signals etc..
UsingfindChildren
it can be done as:QQuickView view; view.setSource(QUrl(QStringLiteral("qrc:/main.qml"))); auto objList = view.rootObject()->findChildren<QObject *>(QString(), Qt::FindChildrenRecursively); for (const auto& obj: objList) { if (obj->inherits("QQmlTimer")) { obj->setProperty("running", false); } }