基本上所有的GUI都不允許在線程中操作GUI
QT也是一樣
那么在QT中如何操作呢?
舉一個例子具體如下:
GUI中
connect(thread,SIGNAL(notify(int)),this,SLOT(updateProgress(int)));
void MainWindow
::updateProgress
(int value
) {
progressbar->setValue(value);
}
Thread中
signals: void notify(int);
Thread run中
emit notify(percent);
很犀利吧