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. qRegisterMetaType() : QMap<QString,long long int>
Forum Update on Monday, May 27th 2025

qRegisterMetaType() : QMap<QString,long long int>

Scheduled Pinned Locked Moved Solved General and Desktop
10 Posts 4 Posters 3.8k 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.
  • ODБOïO Offline
    ODБOïO Offline
    ODБOï
    wrote on last edited by ODБOï
    #1

    Hi,
    I'm trying to pass

    QMap<QString,long long unsigned int>
    or 
    QHash<QString,long long unsigned int>
    

    from one class to another using Signal/Slot but i have this output :

    QObject::connect: Cannot queue arguments of type 'QMap<QString,long long unsigned int>'
    (Make sure 'QMap<QString,long long unsigned int>' is registered using qRegisterMetaType().)
    

    I googled this and found some related topics but can't really understand when/where/how to register my QMap, can someone put me on the right track please ?

    I also wonder if there is another simple method to exchange(using signal/slot) a pair of values (Qstring name, int size)

    Thx in advance

    VRoninV ODБOïO 2 Replies Last reply
    0
    • ODБOïO ODБOï

      Hi,
      I'm trying to pass

      QMap<QString,long long unsigned int>
      or 
      QHash<QString,long long unsigned int>
      

      from one class to another using Signal/Slot but i have this output :

      QObject::connect: Cannot queue arguments of type 'QMap<QString,long long unsigned int>'
      (Make sure 'QMap<QString,long long unsigned int>' is registered using qRegisterMetaType().)
      

      I googled this and found some related topics but can't really understand when/where/how to register my QMap, can someone put me on the right track please ?

      I also wonder if there is another simple method to exchange(using signal/slot) a pair of values (Qstring name, int size)

      Thx in advance

      VRoninV Offline
      VRoninV Offline
      VRonin
      wrote on last edited by
      #2

      @LeLev said in qRegisterMetaType() : QMap<QString,long long int>:

      when/where/how to register my QMap

      When: when you need to pass arguments to a queued connection or to enable creation of objects at run-time
      Where: before using any of the above. Normally it's done directly in the main()
      How: Just call qRegisterMetaType<QMap<QString,long long unsigned int> >();

      I also wonder if there is another simple method to exchange(using signal/slot) a pair of values (Qstring name, int size)

      QPair<QString,int>

      "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
      ~Napoleon Bonaparte

      On a crusade to banish setIndexWidget() from the holy land of Qt

      ODБOïO 1 Reply Last reply
      2
      • VRoninV VRonin

        @LeLev said in qRegisterMetaType() : QMap<QString,long long int>:

        when/where/how to register my QMap

        When: when you need to pass arguments to a queued connection or to enable creation of objects at run-time
        Where: before using any of the above. Normally it's done directly in the main()
        How: Just call qRegisterMetaType<QMap<QString,long long unsigned int> >();

        I also wonder if there is another simple method to exchange(using signal/slot) a pair of values (Qstring name, int size)

        QPair<QString,int>

        ODБOïO Offline
        ODБOïO Offline
        ODБOï
        wrote on last edited by
        #3

        @VRonin thank you very much.

        1 Reply Last reply
        0
        • ODБOïO ODБOï

          Hi,
          I'm trying to pass

          QMap<QString,long long unsigned int>
          or 
          QHash<QString,long long unsigned int>
          

          from one class to another using Signal/Slot but i have this output :

          QObject::connect: Cannot queue arguments of type 'QMap<QString,long long unsigned int>'
          (Make sure 'QMap<QString,long long unsigned int>' is registered using qRegisterMetaType().)
          

          I googled this and found some related topics but can't really understand when/where/how to register my QMap, can someone put me on the right track please ?

          I also wonder if there is another simple method to exchange(using signal/slot) a pair of values (Qstring name, int size)

          Thx in advance

          ODБOïO Offline
          ODБOïO Offline
          ODБOï
          wrote on last edited by ODБOï
          #4

          I tought i was good to go with @VRonin s answer but after putting

          qRegisterMetaType<QMap<QString,long long unsigned int> >()
          

          in my main.cpp or just before the QObject::connect i still have the same error output when the signal is emitted;

          jsulmJ J.HilkJ 2 Replies Last reply
          0
          • ODБOïO ODБOï

            I tought i was good to go with @VRonin s answer but after putting

            qRegisterMetaType<QMap<QString,long long unsigned int> >()
            

            in my main.cpp or just before the QObject::connect i still have the same error output when the signal is emitted;

            jsulmJ Offline
            jsulmJ Offline
            jsulm
            Lifetime Qt Champion
            wrote on last edited by
            #5

            @LeLev said in qRegisterMetaType() : QMap<QString,long long int>:

            in my main.cpp

            Where exactly? Inside main function?

            https://forum.qt.io/topic/113070/qt-code-of-conduct

            ODБOïO 1 Reply Last reply
            1
            • ODБOïO ODБOï

              I tought i was good to go with @VRonin s answer but after putting

              qRegisterMetaType<QMap<QString,long long unsigned int> >()
              

              in my main.cpp or just before the QObject::connect i still have the same error output when the signal is emitted;

              J.HilkJ Offline
              J.HilkJ Offline
              J.Hilk
              Moderators
              wrote on last edited by
              #6

              @LeLev
              I believe, to pass qRegisterMetaType via QueuedConnection you have to register it with a name:
              qRegisterMetaType<MyClass>("MyClass");


              Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


              Q: What's that?
              A: It's blue light.
              Q: What does it do?
              A: It turns blue.

              ODБOïO 1 Reply Last reply
              1
              • jsulmJ jsulm

                @LeLev said in qRegisterMetaType() : QMap<QString,long long int>:

                in my main.cpp

                Where exactly? Inside main function?

                ODБOïO Offline
                ODБOïO Offline
                ODБOï
                wrote on last edited by
                #7

                hi;
                @jsulm said in qRegisterMetaType() : QMap<QString,long long int>:

                Where exactly? Inside main function?

                I tryed before the engine.load , after it, before object creation, after..

                int main(int argc, char *argv[])
                {
                    QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
                    QGuiApplication app(argc, argv);
                  //    qRegisterMetaType<QMap<QString,long long unsigned int> >();
                    Machine m;
                    SysLogTest logger;
                    Sftp_user sftp;
                //      qRegisterMetaType<QMap<QString,long long unsigned int> >();
                    QQmlApplicationEngine engine;
                
                    engine.rootContext()->setContextProperty("sftp",&sftp);
                    engine.rootContext()->setContextProperty("machine",&m);
                    engine.rootContext()->setContextProperty("logger",&logger);
                
                //      qRegisterMetaType<QMap<QString,long long unsigned int> >();
                    engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
                //       qRegisterMetaType<QMap<QString,long long unsigned int> >();
                    if (engine.rootObjects().isEmpty())
                        return -1;
                    return app.exec();
                }
                
                
                J.HilkJ 1 Reply Last reply
                0
                • J.HilkJ J.Hilk

                  @LeLev
                  I believe, to pass qRegisterMetaType via QueuedConnection you have to register it with a name:
                  qRegisterMetaType<MyClass>("MyClass");

                  ODБOïO Offline
                  ODБOïO Offline
                  ODБOï
                  wrote on last edited by
                  #8

                  hello,
                  @J.Hilk said in qRegisterMetaType() : QMap<QString,long long int>:

                  I believe, to pass qRegisterMetaType via QueuedConnection you have to register it with a name:

                  Sorry i don't understand. The error i have is :
                  Make sure 'QMap<QString,long long unsigned int>' is registered using qRegisterMetaType().

                  if i do what you suggested :

                  qRegisterMetaType<MyClass>("MyClass");
                  

                  output >>>

                  C:\Qt\5.11.0\mingw53_32\include\QtCore\qobject.h:449: erreur : 'QObject::QObject(const QObject&)' is private
                       Q_DISABLE_COPY(QObject)
                                      ^
                  
                  1 Reply Last reply
                  0
                  • ODБOïO ODБOï

                    hi;
                    @jsulm said in qRegisterMetaType() : QMap<QString,long long int>:

                    Where exactly? Inside main function?

                    I tryed before the engine.load , after it, before object creation, after..

                    int main(int argc, char *argv[])
                    {
                        QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
                        QGuiApplication app(argc, argv);
                      //    qRegisterMetaType<QMap<QString,long long unsigned int> >();
                        Machine m;
                        SysLogTest logger;
                        Sftp_user sftp;
                    //      qRegisterMetaType<QMap<QString,long long unsigned int> >();
                        QQmlApplicationEngine engine;
                    
                        engine.rootContext()->setContextProperty("sftp",&sftp);
                        engine.rootContext()->setContextProperty("machine",&m);
                        engine.rootContext()->setContextProperty("logger",&logger);
                    
                    //      qRegisterMetaType<QMap<QString,long long unsigned int> >();
                        engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
                    //       qRegisterMetaType<QMap<QString,long long unsigned int> >();
                        if (engine.rootObjects().isEmpty())
                            return -1;
                        return app.exec();
                    }
                    
                    
                    J.HilkJ Offline
                    J.HilkJ Offline
                    J.Hilk
                    Moderators
                    wrote on last edited by J.Hilk
                    #9

                    @LeLev
                    An excerpt from my latest project, maybe it will help you.
                    QVector<quint16>, uint32_t, int32_, uint8_t and TerminalIO::serviceErrors & QModbusDevice::Error( both enumerations) are passed Queued via Signal/Slot

                    int main(int argc, char *argv[])
                    {
                        qRegisterMetaType<QVector<quint16> >("QVector<quint16>");
                        qRegisterMetaType<Datagram>();
                        qRegisterMetaType<QLowEnergyDescriptor>();
                        qRegisterMetaType<QLowEnergyCharacteristic>();
                        qRegisterMetaType<TerminalIO::serviceErrors>("serviceErrors");
                        qRegisterMetaType<uint32_t>("uint32_t");
                        qRegisterMetaType<int32_t>("int32_t");
                        qRegisterMetaType<uint8_t>("uint8_t");
                    
                    #if defined(Q_OS_WIN) || defined(Q_OS_MACOS)
                        qRegisterMetaType<QModbusDevice::Error>("Error");
                    #endif
                    
                        QGuiApplication app(argc, argv);
                    
                    ...
                         QQmlApplicationEngine engine;
                    ...
                         engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
                    
                    return app.exec();
                    }
                    

                    Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


                    Q: What's that?
                    A: It's blue light.
                    Q: What does it do?
                    A: It turns blue.

                    ODБOïO 1 Reply Last reply
                    4
                    • J.HilkJ J.Hilk

                      @LeLev
                      An excerpt from my latest project, maybe it will help you.
                      QVector<quint16>, uint32_t, int32_, uint8_t and TerminalIO::serviceErrors & QModbusDevice::Error( both enumerations) are passed Queued via Signal/Slot

                      int main(int argc, char *argv[])
                      {
                          qRegisterMetaType<QVector<quint16> >("QVector<quint16>");
                          qRegisterMetaType<Datagram>();
                          qRegisterMetaType<QLowEnergyDescriptor>();
                          qRegisterMetaType<QLowEnergyCharacteristic>();
                          qRegisterMetaType<TerminalIO::serviceErrors>("serviceErrors");
                          qRegisterMetaType<uint32_t>("uint32_t");
                          qRegisterMetaType<int32_t>("int32_t");
                          qRegisterMetaType<uint8_t>("uint8_t");
                      
                      #if defined(Q_OS_WIN) || defined(Q_OS_MACOS)
                          qRegisterMetaType<QModbusDevice::Error>("Error");
                      #endif
                      
                          QGuiApplication app(argc, argv);
                      
                      ...
                           QQmlApplicationEngine engine;
                      ...
                           engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
                      
                      return app.exec();
                      }
                      
                      ODБOïO Offline
                      ODБOïO Offline
                      ODБOï
                      wrote on last edited by
                      #10

                      @J.Hilk Perfect thx!
                      this worked

                      qRegisterMetaType<QMap<QString,long long unsigned int> >("QMap<QString,long long unsigned int>");
                      
                      1 Reply Last reply
                      1

                      • Login

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