mentalmushroom
21st June 2011, 10:12
I am using QNetworkAccessManager instance as a static member of my class. When I use my class in another thread and try to call QNetworkAccessManager::post method I receive the following text in the output: "QObject: Cannot create children for a parent that is in a different thread." However everything seems to work fine. Yes, QNetworkAccessManager belongs to a different thread than the one it is used in, but is it really an error to call the post method from another thread, because I don't see any problems except this message?
class MyClass: public QObject
{
//....
static QNetworkAccessManger manager;
//..
}
// my class is then used in the thread
void MyThread::run()
{
MyClass myclass;
myclass.callPostMethod(); // here the warning is printed
}
class MyClass: public QObject
{
//....
static QNetworkAccessManger manager;
//..
}
// my class is then used in the thread
void MyThread::run()
{
MyClass myclass;
myclass.callPostMethod(); // here the warning is printed
}