Important: Please read the Qt Code of Conduct -

QObject::connect: Cannot queue arguments of type 'QMap<QString,int>

  • Hi,

    I want to use


    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 need

    qRegisterMetaType<QMap<QString, int>&>("QMap<QString, int>&");

    though I don't know why, that depends on what you have in your code.

  • Lifetime Qt Champion

    Can you show the full code ?

    If i do

    class MainWindow : public QMainWindow
        MainWindow(QWidget *parent = nullptr);
        QMap<QString, int> data; // the actual list
    private slots:
        void myslot( QMap<QString, int> &p) // slot
            p["test"] = 10;
        void mysignal( QMap<QString, int> &p); // signal
        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 ?

Log in to reply