Qt World Summit: Submit your Presentation

Emit a signal fixed number of time with QTimer

  • Hi All,

    I am working on a project where i draw an ellipse on Graphics View (using scene). I am using QTimer to emit a signal which triggers the SLOT fuction which draws on Graphics View. After drawing for 9 such times, I want to stop and now draw any more. Is there a way to make QTimer not trigger after 9 signals?

    I am using signals to draw on Graphics View, because after each draw I want new ellipse to show immediately. Is there any other solution ?


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    Yes: count the number of occurrences it fired and stop the timer after that.

  • Hi @Anurag2904

    This would help u.

    #include "sample1.h"

    sample1::sample1(QObject *parent) : QObject(parent)
    count = 0;

    void sample1::sLotTimer()

    count ++;
    //business logic
    if(count <= 9){


  • Thanks a lot guys. Issue solved by issuing stop() when counter hits 9

Log in to reply