QObject::connect: Cannot queue arguments of type 'QMap<QString,int>
Unsolved
General and Desktop
-
Hi,
I want to use
QMap<QString,int>
in my signal slot system
but it gives :
QObject::connect: Cannot queue arguments of type 'QMap<QString,int>&' (Make sure 'QMap<QString,int>&' is registered using qRegisterMetaType().)
even I declared in main.cpp
qRegisterMetaType<QMap<QString, int>>("QMap<QString, int>");
why its now working ? any idea ?
-
@RahibeMeryem
Presumably for the message you needqRegisterMetaType<QMap<QString, int>&>("QMap<QString, int>&");
though I don't know why, that depends on what you have in your code.
-
Hi
Can you show the full code ?If i do
class MainWindow : public QMainWindow { Q_OBJECT public: MainWindow(QWidget *parent = nullptr); ~MainWindow(); QMap<QString, int> data; // the actual list private slots: void myslot( QMap<QString, int> &p) // slot { p["test"] = 10; } signals: void mysignal( QMap<QString, int> &p); // signal private: Ui::MainWindow *ui; };
and then in ctor
connect(this, &MainWindow::mysignal, this, &MainWindow::myslot); emit mysignal(data);
it works as expected and i dont get the "Cannot queue arguments"
So are you trying to send signal to/from a other thread `?
or in which way does your code differ ?