3
從QThread
繼承:的QThread - 定義<code>ComSendCallToScreenThread</code>沒有這樣的插槽
class ComSendCallToScreenThread : public QThread
{
private slots:
void readAnswer();
void pauseSendingRequests();
};
void ComSendCallToScreenThread::run()
{
connect(m_senderCom, SIGNAL(readyRead()), this, SLOT(readAnswer()));
connect(m_senderCom, SIGNAL(readyRead()), this, SLOT(pauseSendingRequests()));
}
在運行錯誤報告:
Object::connect: No such slot QThread::readAnswer() in ComSendCallToScreenThread.cpp:47
Object::connect: No such slot QThread::pauseSendingRequests() in ComSendCallToScreenThread.cpp:48
是什麼原因造成的連接失敗?
我注意到你的子類QThread,所以我必須問你是否讀過[this](http://qt-project.org/forums/viewthread/20691)?它聲明'一個QThread只應該管理一個線程,而不是處理數據.'。 – thuga
@thuga介意提供任何建議?真的很感激。 – CDT
好像它在我提供的鏈接的例子中顯示的那樣,創建線程的正確方法是子類'QObject'。然後你將該對象移動到你用'new QThread'創建的線程。 – thuga