Hi all,
I have a problem with QTimer, all I want is to execute a piece of code within a loop each 2 seconds, but nothing happens, here is what I tried:

Qt Code:
  1. void Monitor::mark()
  2. {
  3. QTextCursor cursor(textEdit->document());
  4. colorFormat.setForeground(Qt::red);
  5. cursor.setPosition(j);
  6. if (cursor.movePosition(QTextCursor::NextCharacter, QTextCursor::KeepAnchor, 3))
  7. cursor.mergeCharFormat(colorFormat);
  8. }
  9.  
  10. void Monitor::quickSearch(const char *x, int m, const char *y, int n, QTextEdit *textEdit) {
  11. this->textEdit = textEdit;
  12. j = 0;
  13. int k = 0;
  14.  
  15. while (j <= n - m) {
  16. if (memcmp(x, y + j, m) == 0)
  17. {
  18. //mark();
  19. QTimer::singleShot(2000, this, SLOT(mark()));
  20. }
  21. j += qsBc[y[j + m]];
  22. }
  23. }
To copy to clipboard, switch view to plain text mode 

The method mark() works just fine, when I call him without Qtimer, but I want to have a 2secs pause before doing that.
Tried to search forums, but no results.
Using QT4.5, PCLinuxOS
Please help me, I am out of time