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.
void MainWindow::addModl(QList<QStandardItem*> &data)
{
plmodel->appendRow(data);
}
void MainWindow::addModl(QList<QStandardItem*> &data)
{
plmodel->appendRow(data);
}
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.
void MainWindow::addModl(QList<QStandardItem*> &data)
{
plmodel->appendRow(data);
}
void MainWindow::addModl(QList<QStandardItem*> &data)
{
QCoreApplication::processEvents();
plmodel->appendRow(data);
}
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?
Bookmarks