Best way to run background "algrothim" which updates widgets Qt

279 views Asked by At

So I have an GUI application which was created using a GridLayout. I made a bunch of QLineEdit widgets which need to be updated constantly with new values as they come in. What is the best and most efficient way to do this? Seems like a silly question but I have done some research online and can't seem to find the best and most efficient solution. Thanks in advance.

I tried doing QTimer, it compiles...but never seems to timeout for some reason(I have debug print statement in run() that never gets printed.

    time = new QLineEdit();
    operationMode->setFixedWidth(150);
    layout->addWidget(time, 4,7);

    /*Test*/
    qDebug() << "Here 1";
    QTimer* timer = new QTimer(this);
    timer->setSingleShot(false);
    timer->setInterval(10 * 100); // 1 seconds
    connect(timer, SIGNAL(timeout()), this, SLOT(run()));

    setLayout(layout);
}


void MainWindow::run(void)
{
    qDebug() << "Here 2";
    time->setText(QTime::currentTime().toString());
    qDebug() << "Here 3";
        //qApp->processEvents();

}
1

There are 1 answers

0
user2494298 On

Got my QTimer to work, apparently I needed to run timer->start(1000)