2011/3/23 周鹏 <[email protected]> > Hi,all! > This is my program,it's create a child thread to get the content of a > url,but I got the following error output: > QObject: Cannot create children for a parent that is in a different > thread. > (Parent is QWebPage(0x94fa350), parent's thread is QThread(0x93b04a8), > current thread is Thread(0xbff5d33c) > > The QThread object (and all its member variables and all things created in your (QThread subclass's) constructor belong to the thread the QThread object is created in.
QObjects have an affinity with a single thread. This is usually the thread that creates the QObject So if you create a QObject in the app's main thread and want to use it in another thread, you need to use moveToThread() to change the affinity.This saves having to subclass QThread and creating your objects in the run() method, thus keeping your stuff nicely encapsulated. Read this: http://labs.qt.nokia.com/2006/12/04/threading-without-the-headache/ thanks, Sarvesh
_______________________________________________ webkit-qt mailing list [email protected] http://lists.webkit.org/mailman/listinfo.cgi/webkit-qt
