How to pass custom class reference to QMetaObject::invokeMethod
-
@SJoshi said in How to pass custom class reference to QMetaObject::invokeMethod:
for which I have created its reference here
You created a pointer, not reference.
Where is this demo() method actually defined?
Because you have to pass pointer to class instance to invokeMethod() where demo() is defined.@jsulm Hi I am sorry that I used reference word, actually, demo() is on some another class I didn't mention it on here and it's a public slot too. Also, I have passed the actual object of the class where the demo is put instead of this. But I don't know where I am doing the mistake.
-
@jsulm Hi I am sorry that I used reference word, actually, demo() is on some another class I didn't mention it on here and it's a public slot too. Also, I have passed the actual object of the class where the demo is put instead of this. But I don't know where I am doing the mistake.
-
@jsulm Sure actually it's a bit complex code so I am just sharing the main logic with you :
Q_DECLARE_METATYPE(ABC*)
void MainWindow::senData() { ABC* temp; some logic applied on temp QMetaObject::invokeMethod(pv, "demo", Qt::QueuedConnection, Q_ARG(ABC*, temp), Q_ARG(bool, false)) ... }
In the above logic PV is an object pageView class and created as: pageView* pv = new PageView().
void pageView::demo(ABC* obj, bool handle) { ... }
Error : QMetaMethod::invoke: Unable to handle unregistered datatype 'ABC*
Please let me know If I am missing something.
-
@jsulm Sure actually it's a bit complex code so I am just sharing the main logic with you :
Q_DECLARE_METATYPE(ABC*)
void MainWindow::senData() { ABC* temp; some logic applied on temp QMetaObject::invokeMethod(pv, "demo", Qt::QueuedConnection, Q_ARG(ABC*, temp), Q_ARG(bool, false)) ... }
In the above logic PV is an object pageView class and created as: pageView* pv = new PageView().
void pageView::demo(ABC* obj, bool handle) { ... }
Error : QMetaMethod::invoke: Unable to handle unregistered datatype 'ABC*
Please let me know If I am missing something.
This post is deleted! -
@jsulm Sure actually it's a bit complex code so I am just sharing the main logic with you :
Q_DECLARE_METATYPE(ABC*)
void MainWindow::senData() { ABC* temp; some logic applied on temp QMetaObject::invokeMethod(pv, "demo", Qt::QueuedConnection, Q_ARG(ABC*, temp), Q_ARG(bool, false)) ... }
In the above logic PV is an object pageView class and created as: pageView* pv = new PageView().
void pageView::demo(ABC* obj, bool handle) { ... }
Error : QMetaMethod::invoke: Unable to handle unregistered datatype 'ABC*
Please let me know If I am missing something.
@SJoshi Can you add the include statements prior to Q_DECLARE_METATYPE?
Also, do you use namespaces? -
@SJoshi Can you add the include statements prior to Q_DECLARE_METATYPE?
Also, do you use namespaces?@Asperamanca Yes I declared Q_DECLARE_METATYPE just after the include statements and I'm not using any namespaces.
-
@jsulm Sure actually it's a bit complex code so I am just sharing the main logic with you :
Q_DECLARE_METATYPE(ABC*)
void MainWindow::senData() { ABC* temp; some logic applied on temp QMetaObject::invokeMethod(pv, "demo", Qt::QueuedConnection, Q_ARG(ABC*, temp), Q_ARG(bool, false)) ... }
In the above logic PV is an object pageView class and created as: pageView* pv = new PageView().
void pageView::demo(ABC* obj, bool handle) { ... }
Error : QMetaMethod::invoke: Unable to handle unregistered datatype 'ABC*
Please let me know If I am missing something.
You already have the answer at hand
@SJoshi said in How to pass custom class reference to QMetaObject::invokeMethod:
Unable to handle unregistered datatype 'ABC*
@Asperamanca said in How to pass custom class reference to QMetaObject::invokeMethod:
You need to register the class using [...] qRegisterMetaType()
-
You already have the answer at hand
@SJoshi said in How to pass custom class reference to QMetaObject::invokeMethod:
Unable to handle unregistered datatype 'ABC*
@Asperamanca said in How to pass custom class reference to QMetaObject::invokeMethod:
You need to register the class using [...] qRegisterMetaType()
-
@SJoshi said in How to pass custom class reference to QMetaObject::invokeMethod:
For now, I have used it on the very first line of MainWindow::senData() method.
There is no need to re-register it every time. The ctor of this class is fine.
-
@SJoshi said in How to pass custom class reference to QMetaObject::invokeMethod:
For now, I have used it on the very first line of MainWindow::senData() method.
There is no need to re-register it every time. The ctor of this class is fine.
@Christian-Ehrlicher Thank You!