Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. How Could I stop all timers in Qml?
Qt 6.11 is out! See what's new in the release blog

How Could I stop all timers in Qml?

Scheduled Pinned Locked Moved Solved QML and Qt Quick
2 Posts 2 Posters 1.1k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • W Offline
    W Offline
    W.Y.Kim
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0
    • p3c0P Offline
      p3c0P Offline
      p3c0
      Moderators
      wrote on last edited by
      #2

      @W-Y-Kim There are many ways for eg. finding children, setting context property or using signals etc..
      Using findChildren 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);
              }
          }
      

      157

      1 Reply Last reply
      2

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved