I need to have a computationally intensive function run in a different thread so that the GUI doesn't freeze or turn grey when it's running.
I followed this example: https://stackoverflow.com/a/16501374/2904614
But the GUI still freezes and turns grey.
MainWindow.cpp
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
ui->textBrowser->setFont(QFont("Monospace",11));
ui->textBrowser->setLineWrapMode(QTextEdit::NoWrap);
updater->moveToThread(thread);
connect(updater,SIGNAL(req()), this, SLOT(getCheckSum()));
connect(thread, SIGNAL(destroyed()), updater, SLOT(deleteLater()));
thread->start();
}
When the user clicks the designated button. Since there may be a lot of files in one directory, the GUI will freeze as QDirIterator goes through all of them. I'm hoping to add a progress bar, that will show the user the program is still functioning.
void MainWindow::on_pushButton_clicked()
{
updater->getHash();
//getCheckSum();
}
EDIT
I would like to have the function MainWindow::getCheckSum()
run in a different thread than the GUI. How will I implement this?