Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QObject::connect: Cannot queue arguments of type 'QMap<QString,int>
QtWS25 Last Chance

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

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 3 Posters 688 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    RahibeMeryem
    wrote on last edited by
    #1

    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 ?

    JonBJ 1 Reply Last reply
    0
    • R RahibeMeryem

      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 ?

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by JonB
      #2

      @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.

      1 Reply Last reply
      0
      • mrjjM Offline
        mrjjM Offline
        mrjj
        Lifetime Qt Champion
        wrote on last edited by mrjj
        #3

        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 ?

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved