PDA

View Full Version : Batch image process freezes the GUI



Lymphatus
17th January 2011, 14:06
Hi!

I have an application that aims to resize some pictures, listed in a QTreeWidget.
If I try to do it with a loop in the MainWindow (with a large number of pictures) it causes the GUI to freeze:

for (int i = 0; i < ui->listTreeWidget->selectedItems().count(); i++)
{
QImage image(ui->listTreeWidget->selectedItems().at(i)->text(5));
image.save("test" + QString::number(i), ui->formatComboBox->currentText().toLower().toAscii(), 100);
}

I know that a solution is to use a separate thread, so the GUI won't freeze anymore. I know how to do this, but I can't access the QTreeWidget properties from the QThread, and so I can't load the QImage.
Is there a way to do this? Maybe pass some argument to the QThread from the MainWindow?
Or is there any other solution except using a separate thread?

Thanks for help :)

wysota
17th January 2011, 15:05
Have you read this?
Keeping the GUI Responsive

Lymphatus
17th January 2011, 15:34
No, I didn't read that article :)
Thank you very much!