Unsolved QObject::connect: Cannot queue arguments of type 'std::string' (Make sure 'std::string' is registered using qRegisterMetaType().)
-
I encounter this error when doing Signal-Slot method.
QObject::connect: Cannot queue arguments of type 'std::string'
(Make sure 'std::string' is registered using qRegisterMetaType().)How could I resolve this?
-
@reddy9pp
like the error says, register it to the methadones system viaqRegisterMetaType
or easier, use QString -
mainWindow.h
public: void A(std:string data); signals: void dataReceived(std:string data); private slots: void B(std:string data); private: Ui::MainWindow *ui;
How could I do this without the use of QString?
I also have to implement for cv::Mat type data -
How to register metatypes is explained here. Look at the
Block
- example.
https://doc.qt.io/qt-5/custom-types.html#creating-and-destroying-custom-objects -
@reddy9pp said in QObject::connect: Cannot queue arguments of type 'std::string' (Make sure 'std::string' is registered using qRegisterMetaType().):
I also have to implement for cv::Mat type data
Be very careful as
cv::Mat
is not implicitly shared, it is just shared (i.e. a copy of acv::Mat
object will point to the same data as the copied from item) so it might cause problems if you try to queue arguments of that tipe