Assumme I have a qapplication with a qmainwindow.
In the qmainwindow is a timer emitting the signal timeout(). This signal is connected to a slot computeAlot() which does a lot of computing.

Something like this:

main.cpp
Qt Code:
  1. #include <QApplication>
  2. #include "mainWindow.h"
  3. int main(int argc, char* argv[])
  4. {
  5. QApplication application(argc, argv);
  6. MainWindow mainWindow(0);
  7. mainWindow.show();
  8. return application.exec();
  9. }
To copy to clipboard, switch view to plain text mode 
mainWindow.h:
Qt Code:
  1. #include <QMainWindow>
  2. #include <QTest>
  3. class MainWindow : public QMainWindow
  4. {
  5. Q_OBJECT
  6. public:
  7. explicit MainWindow(QWidget * parent = 0);
  8. private slots:
  9. void computeAlot();
  10. }
To copy to clipboard, switch view to plain text mode 
mainWindow.cpp
Qt Code:
  1. #include "mainWindow.h"
  2. MainWindow::MainWindow(QWidget *parent)
  3. {
  4. const int updateRate = 10; //ms
  5. const Qt::ConnectionType connectionType = Qt::QueuedConnection;
  6. QTimer timer;
  7. connect(timer, SIGNAL(timeout()), this, SLOT(computeAlot()), connectionType);
  8. timer.start(updateRate);
  9. }
  10. MainWindow::ComputeAlot()
  11. {
  12. const int computationTime = 500; //ms
  13. // Should do some computions here
  14. QTest::qSleep(computationTime);
  15. }
To copy to clipboard, switch view to plain text mode 

If the computationTime is higher than the updateRate how often will ComputeAlot() be executed if the timer stops after 100ms? Is it executed 10 times or one time or some threshold times?
Is this behavior dependent of the connectionType?
Would there be a different behavior if the ComputeAlot() would be executed in a different thread?

And if I want the computeAlot() slot be executed as often as possible while the GUI stays responsive, how do i do that? I discovered if I set the updateRate to 0 the GUI is not nicely responsive.

Thanx