How to pass custom class reference to QMetaObject::invokeMethod
-
@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.
-
This post is deleted!
-
@Asperamanca Yes I declared Q_DECLARE_METATYPE just after the include statements and I'm not using any namespaces.
-
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.
-
@Christian-Ehrlicher Thank You!