Important: Please read the Qt Code of Conduct -

Loop not working

  • Hi.
    I'm new to QT and I'm trying to create a project for school using QT and Arduino. I want to send signals to a RGB LED in a loop when I push a button, to light up the LED colors one after another, but the code in the loop does not work:

    void Dialog::on_pushButton_pressed()
    void Dialog::buclaLeduri(){
        int i = 1;
            qDebug() << ledAprins;
            qDebug() << ledStins;

    Any help, please?

  • Lifetime Qt Champion

    Hi and welcome to devnet,

    You are blocking the event loop which is always a wrong idea. Use a QTimer to trigger what you want at regular interval.

  • @SGaist
    the loop will never work, as it can not start when i = 1, and
    the start condition is (i > 10), 1 is not equal or bigger than 10.

  • Lifetime Qt Champion

    @sowas good catch ! The blocking loop pattern made me miss that part.

Log in to reply