what it means by 'Qobject has a parent'
-
Hi,
QObject takes an optional parent in its constructor.
QObject(QObject *parent = nullptr)
You probably created an instance of a class inheriting from QObject, and pass "this" as the parent. In this case just remove the "this" from your code
//MyObject *o = new MyObject(this); MyObject *o = new MyObject;
By the way you can check if an object has a parent using QObject::parent().
-
Hi
Its normally the first parameter in constructor.https://mayaposch.wordpress.com/2011/11/01/how-to-really-truly-use-qthreads-the-full-explanation/
as you see here for the worker class
QThread* thread = new QThread; Worker* worker = new Worker(); <<< no parent given worker->moveToThread(thread);
-
A lot of Qt objects are inheriting from QObject and allow to set a parent, which will be handed down to QObject.
Either you set a parent to take care of handling the object or you leave it as a null pointer (no parent).See more details
-
@koahnig i am new in qt.which type of object(s) can be called as a QObject. As u have mention Qt objects. what is Qt objects?
When a QObject receives a queued signal or a posted event, the slot or event handler will run in the thread that the object lives in. what QObejct means in this sentence.