Hi All,

I am filling a QStandardItemModel with data, in fact 5000 row with 8 columns. At the same time as the model is being filled I am playing a mp3 file via the QMultimedia player and updating a QSlider with the duration.

If I call the function below my main gui thread freezes up and becomes unrepsonsive.

Qt Code:
  1. void MainWindow::addModl(QList<QStandardItem*> &data)
  2. {
  3. plmodel->appendRow(data);
  4. }
To copy to clipboard, switch view to plain text mode 

by calling the processEvents() the problem of the freezing main thread is solved but I have noticed that the QSlider is not updated every 1 seconds, but from to time the update happends with 2-3 seconds delay.



Qt Code:
  1. void MainWindow::addModl(QList<QStandardItem*> &data)
  2. {
  3. QCoreApplication::processEvents();
  4. plmodel->appendRow(data);
  5. }
To copy to clipboard, switch view to plain text mode 




So my question is, is calling the processEvents() the correct approach to prevent the main gui from freezing up?
-and are the gaps I see in the QSLider to be expected.

In my case it is not vital that QSlider is updated every second, but I am thinking there could be other scenarios were you need all widgets to be updated in ms, in that case filling the model the way I am doing is not fine.


What do you guys do when you have to do some heavy operation like this?