q_declare_metatype vs qregistermetatype. The struct is declared in my worker class, which is inside a namespace. q_declare_metatype vs qregistermetatype

 
 The struct is declared in my worker class, which is inside a namespaceq_declare_metatype vs qregistermetatype I have declared all the types with Q_DECLARE_METATYPE, Q_OBJECT and the properties with Q_PROPERTY with the proper getters and setters

Call qRegisterMetaType () to make type available to non-template based functions. namespace CCS { Q_DECL_EXPORT Q_NAMESPACE. This function is useful to register typedefs so they can be used by QMetaProperty, or in QueuedConnections. This function was introduced in Qt 6. There's no such thing as a "const reference" because references are always const -- you can't reseat them. 2)添加声明:利用宏 Q_DECLARE_METATYPE. The ones I am registering for are mostly structs for storing data and just a few simple classes. So using qRegisterMetaType () you will just trade Q_ENUM () for Q_DECLARE_METATYPE (). Hello, Can someone tell me about how to register a metatype in pyqt5. There's also no need for that typedef, it only makes the code less readable. The class is used as a helper to marshall types in QVariant and in queued signals and slots connections. The following should work: Note that you also have to call qRegisterMetaType<MyMpiMessage> (); before you use the function the first time. It associates a type name to a type so that it can be created and destructed dynamically at run-time. c:55 This looks like some loader initialization mismatch, check debug vs release builds of your application and libraries. Registers the type name . I have declared all the types with Q_DECLARE_METATYPE, Q_OBJECT and the properties with Q_PROPERTY with the proper getters and setters. There's also no need for that typedef, it only makes the code less readable. To start viewing messages, select the forum that you want to visit from the selection below. Equivalent to Q_DECLARE_METATYPE(TYPE *) and Q_DECLARE_METATYPE(QQmlListProperty<TYPE>) QML_DECLARE_TYPEINFO (Type, Flags) Declares additional properties of the given Type as described by the specified Flags. h) of the derived class. Thanks for the suggestion. said, try to directly pass shared_ptr with your signal/slots. This allows us to use the Enum as a custom-type of a QVariant, to pass it between QML and Qt, to use it in synchronous signal-slot connections, and to print the symbolic enums (instead of a magic number) with qDebug(). multithreaded software and I am getting the warning says: (Make sure 'QVector<int>' is registered using qRegisterMetaType (). 1. Re: Qt warning of type conversion already registered Originally. If you need the functionality provided by Q_DECLARE_METATYPE, you will have to use it. If I get AnotherQGadgetClass via getter and change it's properties, the setters are called and. What is(are) the good place(s) to put the qRegisterMetaType call? I obviously don't want any expllicit initialization. Also, this Q_DECLARE_METATYPE(SharedTestClass) shouldn't be needed. Adding a Q_DECLARE_METATYPE() makes the type known to all template based functions, including QVariant. One of the overloads is a function template that can be used to create an alias for a type and the form is: qRegisterMetaType<Type> ("alias"); That is, it wants to know the type for which you are declaring something. See also state() and Creating Custom Qt Types. To call qRegisterMetaType (), you still need to use Q_DECLARE_METATYPE (). I thought there was a bug with QMetaType or Q_DECLARE_METATYPE. Read and abide by the Qt Code of Conduct. 1 Answer Sorted by: 21 Objects are copied when put into a QVariant, but QObject derived classes cannot be copied, so the solution is to use a pointer to your. 11. It is meant to be put in a header where the given type is declared. However, as you need the type to be. in a header file and call @qRegisterMetaType<std::unique_ptr<Thing>> ();@ before your signal and slots are used. 1 Answer. Even though we do not intend to use the type with QVariant in this example, it is good practice to also declare the new type with Q_DECLARE_METATYPE(). What is the point of emitting a QSharedPointer? The worker thread reads the files computes the data allocates and fills the memory with data, wraps it in QSharedPointer and passes it to the mainThread, which is used for plotting. The class is used as a helper to marshall types in QVariant and in queued signals and slots connections. Q_DECLARE_META_TYPE (Fruit) and qRegisterMetaType were redundant: #define PluginInterface_iid "pluginInterface" Q_DECLARE_INTERFACE (PluginInterface, PluginInterface_iid) //Actual plugin implementing PluginInterface class. Note: it's also safe to call qRegisterMetaType () multiple times. I have a few instances of QVector<MyClass> which I want them to be exposed to QScriptEngine. So you can call it from your constructor. qRegisterMetaType 必须使用该函数的两种情况. 1. To copy to clipboard, switch view to plain text mode. This version of the function is to register alias types. What worries me is that. ) summary refs log tree commit diff stats Foo and Foo* are different types and need to be registered separately. Returns the internal ID used by QMetaType. Assuming base and derived are Q_GADGETs you want to get a static member. Adding a Q_DECLARE_METATYPE() makes the type known to all template based functions, including QVariant. To start viewing messages, select the forum that you want to visit from the selection below. Declare new types with Q_DECLARE_METATYPE () to make them available to QVariant and other template-based functions. How: I linked qRegisterMetaType. The file (called a "rep" file) uses a specific (text) syntax to describe the API. I just tried. You have to register your class to Qt meta objects system. I can access the property. Good workaround: you may register your type with Q_DECLARE_METATYPE ( IBase * ) macro and wrap your. @Q_DECLARE_METATYPE (std::unique_ptr<Thing>);@. 3 Answers Sorted by: 13 "qRegisterMetaType" is a function. With Q_DECLARE_METATYPE and without qRegisterMetaType: No warning, slot is called With Q_DECLARE_METATYPE and with qRegisterMetaType: No warning, slot is called. g. I tried to write one, but I failed. Qt Base (Core, Gui, Widgets, Network,. 1. Read and abide by the Qt Code of Conduct. Returns the internal ID used by QMetaType. Q_DECLARE_METATYPE, as pointed out by @SingerOfTheFall, would register template based type into QVariant (so it can be retrieved using qvariant_cast<T>()). Re: Qt warning of type conversion already registered Originally. . uint64; If this is your first visit, be sure to check out the FAQ by clicking the link above. Call qRegisterMetaType() to make type available to non-template based functions, such as the queued signal and slot connections. Q_DECLARE_METATYPE. It is only useful to the code that follows it, in the same file. The ENUM type. 14 vs 5. cpp I have to do: qRegisterMetaType<Pkg>("Pkg"); and this does not give errors too, but when I try to create a QVariant(Pkg) I get lots of errors like:cardio63 26 Jan 2016, 10:19. There is no way to add support for more of these value types like std::string (*). To enable using the type in queued signals and such, there also needs to be a corresponding call: qRegisterMetaType<foo::FooState>(); Question. Since Qt 5. So in your case you need to declare. [virtual] QLocalSocket:: ~QLocalSocket Destroys the socket, closing the connection if necessary. Declare new types with Q_DECLARE_METATYPE () to make them available to QVariant and other template-based functions. and Q_DECLARE_METATYPE uses qRegisterMetaType() internally. Share Follow edited Apr 29, 2013 at 7:21 We will still need to register it with the meta-object system at run-time by calling the qRegisterMetaType () template function before we make any signal-slot connections that use this type. This function was introduced in Qt 4. Obviously, a call to qRegisterMetaType<T>(. @kshegunov said in Undocumented automatic metatype registration in Qt6?: Your original code (in the top-mentioned topic) assumes std::unique_ptr is copyable, which it isn't, so it can not ever be a metatype. By the way, Qt 4. Adding a Q_DECLARE_METATYPE() makes the type known to all template based functions, including QVariant. We will still need to register it with the meta-object system at run-time by calling the qRegisterMetaType () template function before we make any signal-slot connections that use this type. See the Custom Type Example for code. F. That said, your stack trace is really strange: _dl_debug_initialize (ldbase=4294967292, ns=1095236752) at dl-debug. So in your case you need to declare. Q_DECLARE_METATYPE QMetaType::type. See also state() and Creating Custom Qt Types. Research The QMetaType class manages named types in the meta-object system. What worries me is that. Make sure you call it from within a method. 8. 2 Answers. no unexpected garbage data or the like). Is your Q_DECLARE_METATYPE in a header file or an implementation file? Incidentally, there is a mistake in TreeItem. io Please note that I do not use Q_DECLARE_METATYPE on purpose because I don't actually need its features (QVariant expansion) right now. QML_DECLARE_TYPE. Similarly you can create a mutable view of type QAssociativeIterable on any container registered with Q_DECLARE_ASSOCIATIVE_CONTAINER_METATYPE(). QMetaType Synopsis Functions def __eq__ (b). qRegisterMetaType vs. 8. template <typename T> struct QMetaTypeId<Container<T>>. For pointer types, it also requires that the pointed to type is fully defined. 11. The object it returns should also be a member of the factory class. The Q_DECLARE_METATYPE() macro and qRegisterMetaType() function documentation contain more detailed information about their uses and limitations. Has anyone else encountered this?See also qRegisterMetaType(). h in the translation unit where you have that line. I only care about runtime instantiation. G. wysota. It must appear in a code block. Call qRegisterMetaType() to make type available to non-template based functions, such as the queued signal and slot connections. [override virtual] bool QAbstractSocket:: waitForBytesWritten (int msecs = 30000) Reimplements:. The ones I am registering for are mostly structs for storing data and just a few simple classes. enum Qt:: ContextMenuPolicycall qRegisterMetaType() to register the data type before you call QMetaMethod::invoke(). call qRegisterMetaType with the name specified, else reading properties. See also state() and Creating Custom Qt Types. There's no need to call qRegisterMetaType that many times, once is enough. Q_DECLARE_METATYPE. 幸哉~ Qt是支持自定义信号,且自定义信号可以发送自定义数据类型的对象。. If you only want to store pointer to Foo with the metatype system, then use qRegisterMetaType<Foo *> ();. I think it would be great if we could run requests in a QThread, but right now it's not possible because the r. Adding a Q_DECLARE_METATYPE () makes the type known to all template based functions, including QVariant. Obviously then you would not do registerComparator (). . This also makes the type available for queued. This requires the exchanged data to be of a type that is recognizable by the engine. But there would be no trouble using the QMetaType class or using qRegisterMetaType before creating an instance of QCoreApplication or QApplication. That's created by this macro. To use the type T in QVariant, using Q_DECLARE_METATYPE() is sufficient. G. To make the type known to this class, we invoke the Q_DECLARE_METATYPE () macro on the class in the header file where it is defined: Q_DECLARE_METATYPE(Message); This now makes it possible for Message values to be stored in QVariant objects and retrieved later. Trying to register std::map<non_template_type_1,non_template_type_2> with Q_DECLARE_METATYPE() results in compilation failure and apparently is not supported. Tried proposed solution using QVariant::fromValue, but kept getting compiler errors of type: . 1. To start viewing messages, select the forum that you want to visit from the selection below. First of all you need to declare your custom object for Qt metatype system. That's probably there, as qRegisterMetaType () wouldn't compile otherwise. the type name must be specified without the class, as in. complains that the metatype isn't registered. Note that if you intend to use the type in queued signal and slot connections or in QObject 's property system, you also have to call qRegisterMetaType () since the names are resolved at runtime. I. PySide6. Detailed Description. To use the type T in queued signal and slot connections, qRegisterMetaType<T>() must be called before the first connection is established. To enable creation of objects at run-time, call the qRegisterMetaType() template function to register it with the meta-object system. There's also no need for that typedef, it only makes the code less readable. QAbstractSocket::SocketState is not a registered metatype, so for queued connections, you will have to register it with Q_REGISTER_METATYPE() and qRegisterMetaType(). 0. The Custom Type, Custom Type Sending and Queued Custom Type examples show how to implement a custom type with the features outlined in this document. See also Thread Support in Qt, QObject::connect(), qRegisterMetaType(), and Q_DECLARE_METATYPE(). Share Improve this answerWe will still need to register it with the meta-object system at run-time by calling the qRegisterMetaType() template function before we make any signal-slot connections that use this type. Also, this Q_DECLARE_METATYPE(SharedTestClass) shouldn't be needed. QLocalSocket. In my module tests, I turn the card up and down, and can verify that the number of signals are increasing using QSignalSpy. You can register a class pointer as the metatype, though. When the plugin is reloaded later, the old declaration still points to the original memory space of the now-unloaded library. I have registered an enumeration type "ClefType" within my header file - this enum is registered with the MetaObject system using the Q_DECLARE_METATYPE and Q_ENUMS macros. Even though we do not intend to use the type with QVariant in this example, it is good practice to also declare the new type with Q_DECLARE_METATYPE(). In practice, both the Q_DECLARE_METATYPE() macro and the qRegisterMetaType() template function can be used to register custom types, but qRegisterMetaType() is only required if you need to perform signal-slot communication or need to create and destroy objects of the custom type at run-time. So I don't stream the pointer itself just copy the properties and set them to a new created pointer object. Step 1 (mark for MOC), build some QObjects That pattern uses Q_PROPERTY and Q_OBJECT and the MoC tool. The Custom Type, Custom Type Sending and Queued Custom Type examples show how to implement a custom type with the features outlined in this document. nyaruko. The class is used as a helper to marshall types in QVariant and in queued signals and slots connections. If you are using queued connections, you need to register std::string as meta type. Also, this Q_DECLARE_METATYPE(SharedTestClass) shouldn't be needed. The class is used as a helper to marshall types in QVariant and in queued signals and slots connections. 4 which does not support all C++11 features. This function returns the Qt meta type id for the type (the same value that is returned from qRegisterMetaType()). . Q_DECLARE_METATYPE (T) requires the type T to be default-constructable, copiable and destructable. Share. Note that if you intend to use the type in queued signal and slot connections or in QObject's property system, you also have to call qRegisterMetaType() since the names are resolved at runtime. 能猜到原因吗?注意看前面 Q_DECLARE_METATYPE() 代码, 对了。类中的成员函数qt_metatype_id中包含对qRegisterMetaType(typeName)的调用: 这儿就是辗转调用了这个带参数的qRegisterMetaType函数: unregisterType(const char *typeName) 函数的作用是取消自己先前注册的某个metatype类型。 and a Context class that holds an instance of MyGadget and exposes a pointer to it to QML via a Q_PROPERTY: #include <QObject> #include "mygadget. Detailed Description. ‎. Qt. To register a type, it must be declared as a meta-type with the Q_DECLARE_METATYPE() macro, and then registered as in the following example:. To start viewing messages, select the forum that you want to visit from the selection below. 基本理解. no unexpected garbage. call qRegisterMetaType with the name specified, else reading properties. An alternative would be to wrap shared_ptr<int> in your own class and implement comparison the way you want. 8. 5 is compiled with GCC 4. Thus you need to use the runtime check QMetaType::type (). Note that if you intend to use the type in queued signal and slot connections or in QObject 's property system, you also have to call qRegisterMetaType () since the names are resolved at runtime. QAbstractSocket::SocketState is not a registered metatype, so for queued connections, you will have to register it with Q_DECLARE_METATYPE() and qRegisterMetaType(). QAbstractSocket::SocketState is not a registered metatype, so for queued connections, you will have to register it with Q_DECLARE_METATYPE() and qRegisterMetaType(). 2. Execute qRegisterMetaType<QItemSelection> (); before it is used as such, e. Re: Q_DECLARE_METATYPE problem. queued connections. In general, you can only export two kinds of C++ types to QML: QObject-derived classes and some build-in value types, see this documentation page. Using the qRegisterMetaType () function The Q_DECLARE_METATYPE () macro is the preferred way to declare a variable in Qt. 如果要使自定义类型或其他非QMetaType内置类型在QVaiant中使用,必须使用该宏。. From the docs: int qRegisterMetaType ( const char * typeName ) Registers the type name typeName to the type T. Remember that Q_DECLARE_METATYPE merely defines a specialization of QMetaTypeId for your type. Note that for enum types, you no not even need to call qRegisterMetaType () in these cases. This results in access violations. void Message:: registerMetaType {qRegisterMetaType < Message >. I just found multiple examples showing the usage of Q_ENUM and Q_ENUMS and looking into the definition of Q_ENUM showed me that it includes Q_ENUMS and other definitions. It will return the same result if it was called before. So you can call it from your constructor. 1. qRegisterMetaTypeしているにもかかわらずQObject::connectでランタイムエラーが出る場合の回避策. qRegisterMetaType() requires also a Q_DECLARE_METATYPE() – dtech. All I want to do is be able to convert this to a byte array in order to send on a socket, and get the object back (deserialize) on the other end. Q_DECLARE_METATYPE. EDIT: When you convert your class to QVariant it uses a. So I played around, copied the original macro and adapted it a bit: @. Note that if you intend to use the type in queued signal and slot connections or in QObject 's property system, you also have to call qRegisterMetaType () since the names are resolved at runtime. Now, that Q_DECLARE_METATYPE enables the type for Qt template classes and QVariant. The logical equivalent of a const T &r (reference to const T) is a const T * const p (const pointer to const T). c:55 This looks like some loader initialization mismatch, check debug vs release builds of your application and libraries. Did you also check the Q_DECLARE_METATYPE macro ? You should declare and register the types properly, lying to qRegisterMetaType will get you in trouble in the long run. cpp. ) I have defined MyStruct in an accessible header file: myheader. You could try using registerConverter () to allow implicit conversion of the shared_ptr<int> to a regular int, and compare them that way. 步骤: (以自定义MyDataType类型为例). The other overload around has almost the same form but for the fact that it. It was also no big issue to call qRegisterMetaType () automatically. QAbstractSocket::SocketState is not a registered metatype, so for queued connections, you will have to register it with Q_REGISTER_METATYPE() and qRegisterMetaType(). As said in int qRegisterMetaType () documentation: To use the type T in QVariant, using Q_DECLARE_METATYPE () is sufficient. I store them in QVariant :. Data Type Conversion Between QML and C++. You can create Q_GADGETS in QML using a C++ factory object registered to be accessible in QML, and a Q_INVOKABLE function in this factory which returns an instance of the Q_GADGET object. That said, your stack trace is really strange: _dl_debug_initialize (ldbase=4294967292, ns=1095236752) at dl-debug. 2. I have a const pointer to a class derived from qobject and want to put into QVariant like below: QVariant::fromValue(objectPointer) I have declared the meta type of derived class using: Q_DECLARE_METATYPE(const QDrivedClass *) in the header file (. Note that if you intend to use the type in queued signal and slot connections or in QObject's property system, you also have to call qRegisterMetaType() since the names are resolved at runtime. hpp and qRegisterMetaType<quint32>("quint32"); in both the Constructors of Class1 and Class2. [quote author="Andre" date="1306394817"]In that case, I think you need to register them. To enable creation of objects at run-time, call the qRegisterMetaType() template function to register it with the meta-object system. I want to use drag-and-drop to drag a QTreeWidgetItem that has std::shared_ptr user data. Even though we do not intend to use the type with QVariant in this example, it is good practice to also declare the new type with Q_DECLARE_METATYPE (). @Wieland Thanks. Declare new types with Q_DECLARE_METATYPE () to make them available to QVariant and other template. Also Q_DECLARE_METATYPE does not register a type, but declares it. See also state(). You may have to register before you can post: click the register link above to proceed. Question: Is there a way to check at compile-time if qRegisterMetaType<T> () was called for a custom type T? The custom type T needs to be registered in Qt meta-type system in order to be used in e. @kshegunov said: you're doing it wrong. QtCore. 1 Answer. You can also use QMetaEnum::fromType() to get the QMetaEnum. qRegisterMetaType vs. J. Adding a Q_DECLARE_METATYPE() makes the type known to all template based functions, including QVariant. As a workaround, I'm using QVariantMap instead of std::map. The Custom Type and Queued Custom Type examples show how to implement a custom type with the features outlined in this document. In the header, after the class declaration, outside the namespace, I've included. cpp 中,用connect函数 将抛出此结构体的信号和接收此结构体的槽函数关联之前,要调用qRegisterMetaType. Similarly you can create a mutable view of type QAssociativeIterable on any container registered with Q_DECLARE_ASSOCIATIVE_CONTAINER_METATYPE(). But I couldn't register the type because it's a QObject and I don't have access to the implementation to change it. h instead ofQVariant x2; x2. Workaround: use a class. The reasoning is found in the discussion on Identity vs Value on the Qt Object Model page. cpp I have to do: qRegisterMetaType<Pkg>("Pkg"); and this does not give errors too, but when I try to create a QVariant(Pkg) I get lots of errors like:cardio63 26 Jan 2016, 10:19. ) I got the hint "expected a declaration" when I tried to use qRegisterMetaType from the global scope in my cpp file. I read a bit and it seems that Q_DECLARE_SMART_POINTER_METATYPE is supposed to allow this to work. Q_DECLARE_METATYPE(Pkg) and this does not give compile errors, but in my main. It would look something like this: Q_DECLARE_METATYPE (MyNamespace::MyClass::MyEnum) However, the Q_DECLARE_METATYPE macro would expand to the following call to qRegisterMetaType: qRegisterMetaType< MyNamespace::MyClass::MyEnum > ("MyNamespace::MyClass::MyEnum",. Q_OBJECT derived class, inheritance. If you want to pass IBase * between different threads, you need to register class with qRegisterMetaType<IBase *> () call; It is bad practice to pass pointers throught singals, because it is hard to control lifetime of passed objects. 9k 9 34 52. 1. void QLocalSocket:: abort ()The Qt docs make it clear that to use a custom type with Queued Connections, I need to use both Q_DECLARE_METATYPE and qRegisterMetaType. The third without Q_DECLARE_METATYPE. Q_DECLARE_METATYPE. uint64; If this is your first visit, be sure to check out the FAQ by clicking the link above. Update. This also makes the type available for queued. 12. 0 and have problems registering my own class as a QMetaType. 0. qRegisterMetaType vs. uint64; If this is your first visit, be sure to check out the FAQ by clicking the link above. 手册中告诉我们,执行这个的时候,模板参数T必须用 Q_DECLARE_METATYPE() 声明过 能猜到原因吗?注意看前面 Q_DECLARE_METATYPE() 代码, 对了。类中的成员函数qt_metatype_id中包含对qRegisterMetaType(typeName)的调用 这儿就是辗转调用了这个带参数. Q_DECLARE_METATYPE ( blabla* ) Also qRegisterMetaType<T> () is only required for sending your object through queued signal/slot connections. To start viewing messages, select the forum that you want to visit from the selection below. QObject::connect: Cannot queue arguments of type 'MyStruct'. Adding a Q_DECLARE_METATYPE() makes the type known to all template based functions, including QVariant. The following code will work as well: using namespace foo; Q_DECLARE_METATYPE (MyClass) Teams. Call qRegisterMetaType() to make types available to non-template based functions, such as the queued signal and slot connections. Q&A for work. For this, a function call (evaluated during runtime) needs to be made, and qRegisterMetatype is the tool for this: qRegisterMetaType<Area>("Area");@julio. c:55 This looks like some loader initialization mismatch, check debug vs release builds of your application and libraries that are used. It is not safe to make a QObject's copy constructor public. Call qRegisterMetaType<std::string> (); in the initialization of your code. It associates a type name to a type so that it can be created and destructed dynamically at run-time. Without this reference, it compiles just fine. Also you may need to use qRegisterMetaType function. c:55 This looks like some loader initialization mismatch, check debug vs release builds of your application and libraries that are used. So in both cases qRegisterMetaType isn't required for the slot to be called and the custom type to be accessible within the slot (i. Note that if you intend to use the type in queued signal and slot connections or in QObject 's property system, you also have to call qRegisterMetaType () since the names are resolved at runtime. Now I want to read this property with Qt's meta object system. 4] QString QWebSocket:: subprotocol const. You may have to register before you can post: click the register link above to proceed. First of all, you always need to declare your meta type: Q_DECLARE_METATYPE (foo::MyClass) It works at compile time, so there are no limitations on how you refer to your class. e. The docs only talk about class or struct with public default constructor, copy constructor and. Using the macro directly turned out to be impossible. 基本理解. Q_DECLARE_METATYPE accepts objects with public constructor, copy constructor and destructor. @Q_DECLARE_METATYPE (std::unique_ptr<Thing>);@. The documenation of this macro gives. There's also no need for that typedef, it only makes the code less readable. This function was introduced in Qt 4. Here you can see that the macro expands to nothing. void QLocalSocket:: abort ()The signal "orientationChanged" includes an enum of type "Orientation" to indicate if the card has been turned up or down. Q_DECLARE_METATYPE QMetaType::type. Labels: meta system, Meta type, qt. The correct syntax is Q_DECLARE_METATYPE (std::string) without the ;. x however, the code generated by moc will call qRegisterMetaType for you if moc can determine that the type may be registered as a. I want to use my objects as QVariants and for queued connections. Registered enumerations are automatically registered also to the Qt meta type system, making them known to QMetaType without the need to use Q_DECLARE_METATYPE(). Learn more about Teams I can't figure out a way to automatically declare a meta type, i. goocreations 12 Mar 2013, 07:22. First of all you need to declare your custom object for Qt metatype system. Some structure need to be registered to be queued in asynchronous signals using qRegisterMetaType<T>(name), such as signal which passes QVector<int>. All I want to do is be able to convert this to a byte array in order to send on a socket, and get the object back (deserialize) on the other end. Any class or struct that has a public constructor, a public copy constructor, and a public destructor can be registered. Call qRegisterMetaType() to make types available to non-template based functions, such as the queued signal and slot connections. The class is used to send arguments over D-Bus to remote applications and to receive them back. Re: Q_DECLARE_METATYPE vs qRegisterMetaType for non global namespace classes (QTest) The reason for this behavior might be caused by the fact that runtime signal/slot connections are checked by string manipulation - both Q_DECLARE_METATYPE, SIGNAL, SLOT macros and 'moc' are (among other things) converting type-names to text and pass it along. waitForConnected ([msecs=30000]) # Parameters: msecs – int. staticMetaObject is of type QMetaObject and provides access to the enums declared with Q_ENUMS. Output:Additionally Q_DECLARE_METATYPE and qRegisterMetaType are not purposed to be used for QObject derived classes. Then you should register your object to use it with QML. If you want both, then register both. There's no need to call qRegisterMetaType that many times, once is enough.