Another option is to use QApplication:rocessEvents()
I see. It works.
I inserted QApplication:rocessEvents() inside the while loop:

Qt Code:
  1. while(sqlalarm)
  2. {
  3. mysql_real_query(&mysql, comando.constData(), comando.size());
  4. QCoreApplication::processEvents();
  5. }
To copy to clipboard, switch view to plain text mode 
and it works.

Which is the best approach in your opinion? This with the processEvents or creating an extra thread?