[webkit-qt] QObject: Cannot create children for a parent that is in a different thread
aquarian.thunder at gmail.com
Wed Mar 23 01:47:17 PDT 2011
2011/3/23 周鹏 <zhoupeng19 at 126.com>
> 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
> (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.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the webkit-qt