Greeting
I have a following class.
class MyClass : public QObject
{
Q_OBJECT
public:
Q_INVOKABLE QVariant status();
public:
MyClass(ClassX * classX);
public slots:
void slotA();
void slotB();
signals:
void signalA();
void signalB();
private:
void init();
void doSomething();
private:
ClassX * classX;
ClassA classA;
ClassB classB;
};
In MyClass
's constructor, I set classX
to this.classX
and in init()
, I connect
some of classX
signals to MyClass
slots and wise-versa and in someFunction()
i use classA
and classB
.
In my controller
class in main thread, I create MyClass
object and run it inside different thread.
MyClass * myClass = new MyClass(classX);
connect(&myClassThread, SIGNAL(started()), myClass, SLOT(init()));
myClass->moveToThread(&myClassThread);
myClassThread.start();
I see the following warning in qDebugger
.
QObject::setParent: Cannot set parent, new parent is in a different thread
Can anyone tell me why i get that warning ?
Thanks in advanced
PS 1: The classX
created in main thread.
PS 2 : Remember, Everything work fine and i don't have any problem, I just want to know the reason of this warning and how to fix it.
PS 3 : I also use the following command in main thread to expose the object in javascript
.
webFrame->addToJavaScriptWindowObject("myClassObject", myClass);
Edit 1 : QThread myClassThread is class member.
Edit 2 : I believe the lack of information, confused you guys and i'm sorry about that.
The constructor of MyClass
is like this :
MyClass::MyClass(ClassX * classX)
{
this.classX = classX;
}