我使用下面的代碼。但我得到了像QT Thread_問題
THREAD Started
QObject: Cannot create children for a parent that is in a different thread.
(Parent is CGNetwork(0x10151d0d0), parent's thread is QThread(0x1016015b0), current thread is RenderThread(0x10155de40)
代碼中的錯誤:
RenderThread.cpp
RenderThread::RenderThread(CGNetwork *cgnetwork)
{
cityUrl = "http://112.138.3.181/City/Cities";
categoryUrl = "http://112.138.3.181/City/Categories";
cgnetworks = cgnetwork;
start();
}
void RenderThread::run()
{
qDebug()<< "THREAD Started";
cgnetworks->getCityList(cityUrl);
}
請幫助我。提前致謝。
嗨..我使用以下方法。它是否正確? void RenderThread :: run() CGNetwork oCgNetwork; qDebug()<<「THREAD Started」<< cityUrl; oCgNetwork.getCityList(cityUrl); } 請幫助我。 – Finder 2010-09-30 14:24:22
如果您在'run'方法中創建'CGNetwork'對象,它已經屬於所需的QThread - 'RenderThread'。 – 2010-09-30 17:02:50
謝謝。我發佈我的問題是作爲另一個問題(http://stackoverflow.com/questions/3836474/qt-thread-call-issues)。你能解決我的問題嗎?謝謝你提前... – Finder 2010-10-01 04:13:25