我有一種奇怪的情況,其中有一個工作線程完成它的工作,然後發出一個信號來回調GUI線程來關閉對話框。是否有人可以解釋爲什麼這個工程:在QT應用程序中沒有接收信號的插槽
的WorkerThread:
[Header]
signals:
void writeComplete(void);
[Source]
void startWorkerThread()
{
// do some stuff in boost::thread
emit writeComplete();
}
主窗口的子類:
burnDialog = new QProgressDialog("Writing to disc", "", 0, 0);
burnDialog ->setCancelButton(0);
QWidget::connect(discHandler.get(), SIGNAL(writeComplete()), burnDialog, SLOT(close()));
QWidget::connect(discHandler.get(), SIGNAL(writeComplete()), this, SLOT(close()));
burnDialog->open();
discHandler->startWorkerThread();
但這並不:
主窗口的子類: [標題] 公衆插槽: void closeWithDialog(void);
[Source]
burnDialog = new QProgressDialog("Writing to disc", "", 0, 0);
QWidget::connect(discHandler.get(), SIGNAL(writeComplete()), this, SLOT(closeWithDialog()));
burnDialog ->setCancelButton(0);
burnDialog->open();
discHandler->startWorkerThread();
void closeWithDialog()
{
burnDialog->close();
close();
}
是否[此答案](http://stackoverflow.com/a/2074064/894321)解決您的問題? – alexisdm