qregistermetatype. qmlRegisterType<Person> ("People", 1,0, "Person"); This would register the C++ class "Person" as a QML element also called "Person", into the module "People" under the version 1. qregistermetatype

 
qmlRegisterType<Person> ("People", 1,0, "Person"); This would register the C++ class "Person" as a QML element also called "Person", into the module "People" under the version 1qregistermetatype  Hm

// to be declared somewhere Q_DECLARE_METATYPE(std::string); // to be invoked at the beginning of program qRegisterMetaType<std::string>(); Without type registration Qt doesn't know how to do a copy and provides a warning in logs. Step 2 (meta type Declare macro), if needed, describe your custom type/class to things like QVariant, QDebug and other "support" systems used everywhere on QObjects. So if you put the register in constructor, you have to instance your class once and then make the connection. Note following line #include. Since you're passing the parameter via a pointer you don't need to register the type AFAIK. Where are you getting this from? qRegisterMetaType is not a member function of QSettings or any other class. This replaces the now-deprecated Q_ENUMS and will automatically register the metatype. Tested on Linux Ubuntu. 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 (). MyEnum needs to be registered with qRegisterMetaType. ) I read on some forum, that this may be caused by calling qt-functions from another Thread, and that using signals & slots instead of plain function calling may fix the issue, but i have tried signals aswell, and i. Good workaround: you may register your type with Q_DECLARE_METATYPE ( IBase * ) macro and wrap your. The physical memory sizes returned include the memory from all nodes. QSharedPointer is a smart pointer class in the Qt library. . In both. cpp</code> file implementing <code>YourType</code>. qRe gisterMetaType 的函数原型为: ```c++ template < type name T> int. 13. To use the type T in queued signal and slot connections, qRegisterMetaType () must be called before the first connection is established. C++ (Cpp) qmlRegisterUncreatableMetaObject - 2 examples found. ) ^C[rviz-2] killing on exit [laserMapping-1] killing on exit Hello guys, i have the following message when i run the launch file. Placing logic such as a script or other operations in the handler. cpp 0: 142: 143: If c MyStruct is in a namespace, the Q_DECLARE_METATYPE() macro: 144: has to be outside the namespace: 145: 146adam-iris modified the milestone: Beta Release Aug 25, 2017. qRegisterMetaType<MyStruct>("MyStruct"); 若已经使用 Q_DECLARE_METATYPEQ 标记过该类型,可以使用其不带参数的版本: qRegisterMetaType<MyStruct>(); 同样的,若对象包含在自定义的命名空间中时,注册时要带上完整的命令空间,如: qRegisterMetaType<NSP::MyStruct>("NSP::MyStruct"); Note that for enum types, you no not even need to call qRegisterMetaType () in these cases. FlightTab:Changed effect to 0 You do not have the required permissions to view the files attached to this post. If the signal is being emitted, I get this error: @. Returns the internal ID used by QMetaType. In variant 1 the call is invoked immediately like in direct connection. Unless the property is readonly, you can also set a binding on this property. See also qRegisterMetaType(). 1,609 4 22 34. This function was introduced in Qt 6. Use wakeOne() to wake one randomly selected thread or wakeAll() to wake them all. no unexpected garbage. ) but does not allow the transmission of data between threads, for this case it must be registered using qRegisterMetaType<MyClass::ErrorCode>("ErrorCode"): main. . Fixes #46, the logging handler was trying to update a GUI element dir…. You could also Q_DECLARE_METATYPE to register your custom type and then use qMetaTypeId () to get the metaType id. (Parent is QTcpSocket (0x24a6ce8), parent's thread is ServiceSlots. Its probably something about Qt, but how can i fix it ?Member Function Documentation [explicit] QQmlEngine:: QQmlEngine (QObject *parent = nullptr) Create a new QQmlEngine with the given parent. aa73c08. tabs. websocket. The central feature in this model is a very powerful mechanism for seamless object communication called signals and slots . 11. Hello, when I run rviz_sim. Hello, Can someone tell me about how to register a metatype in pyqt5. QObject::connect: Cannot queue arguments of type 'QVector<int>'. Maybe qRegisterMetaType is what you missed. childEvent (event) # Parameters:. beginGroup("references/"); QStringList keys = settings. 1、自定MyDataType 类型,在这个类型的顶部包含:#include <QMetaType>. The actual values () are either single bit or. py that implements a customwidget class it would look something like: from customwidgetscript import customwidget. This is the same as indexOfMethod (), except that it will return -1 if the method exists but isn't a signal. bool QMetaProperty:: writeOnGadget ( void * gadget, const QVariant & value) const. This function should only be used if this is a property of a Q_GADGET. call qRegisterMetaType with the name specified, else reading properties. QtCore. Through two classes, QObject and QVariant, Qt brings us introspection, makes it easier to manage memory in C++ and makes it easier to decouple classes. Provide details and share your research! But avoid. Undeclared QMetaObject::SuperData. qRegisterMetaType<FileNodePointer> ("FileNodePointer"); should be called once (in main, constructor etc. childKeys();@J. In general, you only need Q_DECLARE_METATYPE (). Improve this answer. An alternative would be to wrap shared_ptr<int> in your own class and implement comparison the way you want. 如果要使自定义类型或其他非QMetaType内置类型在QVaiant中使用,必须使用该宏。. (Make sure 'QVector<int>' is registered using qRegisterMetaType (). Qt documentation specifically states that qRegisterMetaType<T>() must be called for a type to work in the Qt property system. Problem using qRegisterMetaType. 原因:当_qregistermetatype qRegisterMetaType的使用-程序员宅基地 - 程序员宅基地 程序员宅基地 程序员宅基地,技术文章由你所想念有所思See also QLocalSocket::state(). registerType () determines which register is used for the operations. A QWindow created with the surface type RasterSurface can be used in combination with QBackingStore and QPainter , Qt’s highly optimized 2D vector graphics API. You need to (or at least this is how it works for me) create a signal that will be emitted every iteration of the for loop in your thread. Usually, I do this type of updates using signals and slots, but the run function is not PyQt specific. QObject. Then, connect this signal to a slot that will do the actual update of the data. So unless you're deliberately creating a typedef registration (and even inThe QObject-based version has the same internal state, and provides public methods to access the state, but in addition it has support for component programming using signals and slots. Did you try to use qRegisterMetaType function? The official manual says: The class is used as a helper to marshall types in QVariant and in queued signals and slots connections. When data values are exchanged between QML and C++, they are converted by the QML engine to have the correct data types as appropriate for use in QML or C++. A connection defines an interface for sending/receiving data independent of the protocol. From Qt documentation: Ideally, this macro should be placed below the declaration of the class or struct. This requires the exchanged data to be of a type that is recognizable by the engine. This maybe is not the nicest solution, but it works just fine: Add a property to the wizardpage which contains the QListView and let it return the pointer to the selectionmodel. qRegisterMetaType<foo::FooState>(); Question. 2 Answers Sorted by: 3 You do not need to call qRegisterMetaType () to use a type with QVariant. ). An alternative would be to wrap shared_ptr<int> in your own class and implement comparison the way you want. 则QML中可直接使用 MainController。. can include digits and underscore). So, what is the right way to get rid from: QObject::connect: Cannot queue arguments of type 'QTextCursor' (Make sure 'QTextCursor' is registered using qRegisterMetaType (). Share. The Windows registry and INI files use case-insensitive keys, whereas the CFPreferences API on macOS and iOS uses case. Wrong code @ QSettings settings; settings. @SGaist if you see the original question I posted the contents of the devicepresence. Registration is not required for most operations; it’s only required for operations that attempt to resolve a type name in string form back to a QMetaType object or the type’s ID. I got confused by the documentation and I declared my typedef on line 10 and then I put qRegisterMetaType<AvailablePorts>("AvailablePorts") on line 11. From the QVariant::operator== documentation. Call qRegisterMetaType() to make types available to non-template based functions, such as the queued signal and slot connections. To call qRegisterMetaType (), you still need to use Q_DECLARE_METATYPE (). Custom types registered using qRegisterMetaType() that have operators for streaming to and from a QDataStream can be stored using QSettings. . QTextCharFormat. said, try to directly pass shared_ptr with your signal/slots. I am trying to learn Qt and I am attempting to do so by making a little titres game. Reproducible Example Of The. This event handler can be reimplemented in a subclass to receive child events. metaObject()->indexOfSlot("testFunc ()"); QMetaMethod mm = win. Also you may need to use qRegisterMetaType function. There is no use case for implementing qRegisterMetaType, because PyObject. . [override virtual noexcept] QQmlEngine:: ~QQmlEngine Destroys the QQmlEngine. h #pragma once #include <QThread>. This way your metatype will be registered once at startup, and the registration is close by the implementation and does not require to modify <code>main</code>. But the problem comes up when I try to send it to C++ slot, that have my enum as parameter. If you want both, then register both. If you need a socket, you have two options: Instantiate QTcpSocket or QUdpSocket. Last updated at 2016-07-08 Posted at 2015-11-16. I searched the Doc but I could not find a documentation to. Registering a metatype shouldn't prevent you from disconnecting a signal. ) My application is an image viewer. answered May 10, 2013 at 2:25. QtのAPIのドキュメントに、thread-safeと書いてない限りは、QMutex等を使って自分で排他をする必要がある。. Any class or struct that has a public default. The central feature in this model is a very powerful mechanism for seamless object communication called signals and slots. 1 Answer. You can call this function in a subclass of QAbstractSocket to change the return value of the localPort () function after a connection has been established. It is more or less explained in the manual for int qRegisterMetaType (const char *typeName) This function requires that T is a fully defined type at the point where the function is called. The correct syntax is Q_DECLARE_METATYPE (std::string) without the ;. Data Type Conversion Between QML and C++. 15. Data Type Conversion Between QML and C++. 0’ of a module called ‘com. Share. 1 Reply Last reply 0. Writes value as the property's value to the given gadget. For pointer types, it also requires that the pointed to type is fully defined. Someone may be able to correct me here, but I don't think you should be needing to register the type int&. When data values are exchanged between QML and C++, they are converted by the QML engine to have the correct data types as appropriate for use in QML or C++. QtCore import QObject works. [since 6. pro file: CONFIG += qmltypes. It associates a type name to a type so that it can be created and destructed dynamically at. If I register QVector I can't dissconnect this signal and the signal is emited. QVariant’s operator== now uses QMetaType::equals for the comparison. 9k 13 13 gold badges 106 106 silver badges 138 138 bronze badges. Then you should register your object to use it with QML. 16. cppuint64 is a typedef for 64 bit integers in VS: Qt Code: Switch view. That always worked in Qt4, but in Qt5 I get the following error: @error: specializing member ‘::qRegisterMetaType’ requires ‘template<>’ syntax@ qRegisterMetaType("Subclass") also doesn't workI am using ubuntu 16. E. Q&A for work. How to properly use qRegisterMetaType on a class derived from QObject? I couldn't understand from the answer to where I have to define the specialization of qMetaTypeConstructHelper. The following code will work similarly: using namespace foo; qRegisterMetaType<MyClass> ("MyClass"); qRegisterMetaType<MyClass> ("foo::MyClass"); For example, the "MyClass" and "foo::MyClass" strings are used to identify argument types when you refer to your signals and slots. Sorted by: 5. Hi Gabriel, good that my answer was helpful :) you’re right, basically the entire Pyqt library will only work within classes. Detailed Description. The default value is Data8, i. A QItemSelection is basically a list of selection ranges, see QItemSelectionRange. I made some experiments with moving . Returns true if the column is inserted; otherwise returns false. The QObjectList class is defined in the <QObject> header file as the following: typedefQList<QObject*>QObjectList; The first child added is the first object in the list and the last child added is the last object in the list, i. ) Is this a reminder t. This requires the exchanged data to be of a type that is recognizable by the engine. ) This is hard to track, so I would. However, as you need the type to be. QModbusDataUnit can be used for read and write operations. Improve this answer. Selected questions and answers have been migrated, and redirects have been put in place to direct users to the. You can define one with the enum keyword. and another folder with the obj files. . If any data was written, this function returns true; otherwise false is returned. uint8_t is the typedef for unsigned char . ) QObject::connect: Cannot queue arguments of type 'QVector<int>'. 11. ChildAdded and ChildRemoved events are sent to objects when children are added or removed. Its probably something about Qt, but how can i fix it ?Member Function Documentation [explicit] QQmlEngine:: QQmlEngine (QObject *parent = nullptr) Create a new QQmlEngine with the given parent. ) It still works but point to the fact that I am doing something wrong, and I am not sure that I will keep working when more threads are active. Here's the twist: this class is contained in a shared library, and therefore I want to avoid instructing anyone using my library to call qRegisterMetaType. Even if it works now, it may fail with new Qt versions. This property holds the state (high or low) of the line signal DTR. QPainter::begin: Paint device returned engine == 0, type: 3 QPainter::setFont: Painter not active QPainter::setPen: Painter not active [ INFO] [1432901455. evaluate("1 + 2"); evaluate () returns a QScriptValue that holds the result of the evaluation. Detailed Description. QtCore. I'm not sure how to do this in python but. )Note: If the setting is set before opening the port, the actual serial port setting is done automatically in the QSerialPort::open () method right after that the opening of the port succeeds. 3. Use Q_DECLARE_METATYPE (std::string) in one of your headers. I read on documentation that Q_DECLARE_METATYPE makes available type to QVariant, for example (I got it from documentation): @ struct MyStruct { int i;. So I saw this in the documentation: typedef QString CustomString;. Improve this answer. Obviously then you would not do registerComparator (). Someone may be able to correct me here, but I don't think you should be needing to register the type int&. self. 15. QObject: Cannot create children for a parent that is in a different thread. I'm using Qt 5. The following code allocates and destructs an instance of MyClass: The Q_DECLARE_METATYPE() macro and qRegisterMetaType() function documentation contain more detailed information about their uses and limitations. October 21, 2020 by Fabian Kosmale | Comments As you might know, Qt has a metatype system which provides run-time dynamic information about types. ). QtGui. 0. This function requires that T is a fully defined type at the point where the function is called. ) The text was updated successfully, but these errors were encountered: QObject::connect: Cannot queue arguments of type 'object' (Make sure 'object is registered using qRegisterMetaType(). You can use the tags to annotate your methods. Hello, Can someone tell me about how to register a metatype in pyqt5. Any class or struct that has a public default constructor, a public copy constructor and a public destructor can be registered in QMetaType. That's not. ) You can read about how to call qml functions from c++. 0. It also reflects the size of the paging file at that time. Using qRegisterMetaType() is actually registering a certain type to QMetaType. A. int QMetaObject:: indexOfSignal (const char * signal) const. cpp; so you will have. If you wanted to user the new-style signals, then it would look more like: class TwitterThread (QThread): newStatuses = pyqtSignal (object). Detailed Description. ui. After about 20 seconds of running LOAM, the laserOdometry module crashes with [laserOdometry-2] process has died [pid 6983, exit code -11, cmd /home/ab. 0. I created a. The class is used as a helper to marshall types in QVariant and in queued signals and slots connections. To not see the message. Also, to use type T with the QObject::property() API, qRegisterMetaType() must be called before it is used, typically in the constructor of the. And even you make right signature, you will not be able to connect that signal and slot due to their signature mismatch. If you ever wondered what does Q_DECLARE_META_TYPE or qRegisterMetaType do and when to use (or not to use) them, read on. The QML engine provides built-in support for a. One of these objects is a Connection. 因为没有指定 connect的链接方向 Qt::DirectConnection. Detailed Description. (Make sure 'QDomDocument' is registered using qRegisterMetaType(). FollowQObject::connect: Cannot queue arguments of type 'QProcess::ProcessError' (Make sure 'QProcess::ProcessError' is registered using qRegisterMetaType(). QObject::connect: Cannot queue arguments of type 'QList<QPersistentModelIndex>' (Make sure 'QList<QPersistentModelIndex>' is registered using qRegisterMetaType(). an int and a std::string. QObject::connect: Cannot queue arguments of type 'QVector<int>' (Make sure 'QVector<int>' is registered using qRegisterMetaType(). 5] int qRegisterMetaType (QMetaType meta) Registers the meta type meta and returns its type Id. A QVariant containing a pointer to a type derived from QObject will also return true for this function if a qobject_cast to the template type T would succeed. It is. (Make sure 'QTextCharFormat' is registered using qRegisterMetaType(). (Make sure 'QTextBlock' is registered using qRegisterMetaType (). rep file extension, short for Replica. See also Q_DECLARE_METATYPE() and qRegisterMetaType(). Toggle Light / Dark / Auto color theme. emit() self. e. The QML engine provides built-in support for a. Detailed Description. I have gave you below the basic process for a deletion for example. h which looks like: #ifndef ENUMS_H #define ENUMS_H #include <QtDBus> #include "enumDBus. qmlRegisterType makes the QObject (MyClass) class accessible in QML (Q_PROPERTY, Q_ENUM, Q_SIGNAL, Q_SLOT, Q_INVOKABLE, etc. Returns the access specification of this method (private, protected, or public). But with the shared_ptr object, not a pointer to the shared pointer! You will have to register std::shared_ptr<yourclass> with the Qt meta object system before this can work, i. Sorted by: 5. Note that, as far as the meta-type system is concerned, MyClass, MyClass *, QVector<MyClass>, shared_ptr<MyClass> and so on are all different types, and as such, each one may need its own registration. Each emission of the signal will append one item to the list, containing the arguments of the signal. ", which suggests it is only for classes and structs. You can use the tags to annotate your methods. Doc states:. Only users with topic management privileges can see it. I don't really know what I have to do in addition. And then Python crashes. The qRegisterMetaType function essentially allows a typedef or alias to be assigned to a QVariant. ) QObject::connect: Cannot queue arguments of. If you are using the Python logging module to can easily create a custom logging handler that passes the log messages through to a QPlainTextEdit instance (as described by Christopher). the type name must be specified without the class, as in. hEvaluating Scripts. The habit of passing shared_ptr by ref should not be followed in lambdas. Also, to use type T with the QObject::property() API, qRegisterMetaType() must be called before it is used, typically in the constructor of the class. How to register custom type with QML if it is passed as const from C++. I had to uninstall it first, then reinstall it: # upgrade pip python3 -m pip install --upgrade pip # uninstall python3 -m pip uninstall PyQt5 python3 -m pip uninstall PyQt5-sip python3 -m pip uninstall PyQtWebEngine # reinstall python3 -m pip install PyQt5 python3. bool QAbstractItemModel:: insertColumn ( int column, const QModelIndex & parent = QModelIndex ()) Inserts a single column before the given column in the child items of the parent specified. I. 5 times (ie. And once all of them are updated I'd like the Context object to inform QML to update the view. emit (foo_text) def settext ( self, text ): print (text) Im sure you guys get this alot but im trying to thread and im getting this error: (Parent is QTextDocument (0x1243bfd4290), parent's thread is QThread (0x12437dd1260), current thread is. e. ) I got the hint "expected a declaration" when I tried to use qRegisterMetaType from the global scope in my cpp file. com. QObject::connect: Cannot queue arguments of type 'my_enum' (Make sure 'my_enum' is registered using qRegisterMetaType(). 2 Answers Sorted by: 3 You do not need to call qRegisterMetaType () to use a type with QVariant. This line has disappeared in Qt 5. The Windows registry and INI files use case-insensitive keys, whereas the CFPreferences API on macOS and iOS uses case. Make sure 'QTextCursor' is registered using qRegisterMetaType(). Call qRegisterMetaType<std::string> (); in the initialization of your code. I don't really know what I have to do in addition. Sets the port on the local side of a connection to port. It associates a type name to a type so that it can be created and destructed dynamically at run-time. QObject::connect: Cannot queue arguments of type 'ProcessHandle*const' (Make sure 'ProcessHandle*const' is registered using qRegisterMetaType(). It seems that for a metatype that is a QList<MyClass::MyEnum> I must. ; Create a native socket descriptor, instantiate QAbstractSocket, and call setSocketDescriptor() to wrap the native socket. G. tab) self. For example, let's suppose that we have three. [override virtual noexcept] QQmlEngine:: ~QQmlEngine Destroys the QQmlEngine. Without this binding click will result in no action. qRegisterMetaType you'll need if creating objects by class name dynamically, and it seems for queued connections, generally you won't. cpp2 Answers. FollowThis can be made to work but it turns out there's a bit of manual labour to be done. I explicitly don't want to update it on every change to one of the quantities, so they don't. The type and its values must start with a capital letter but otherwise follow rules for naming a variable (e. 根据类型名. Be very careful as cv::Mat is not implicitly shared, it is just shared (i. Represents a handle to a signal-slot (or signal-functor) connection. ) I read on some forum, that this may be caused by calling qt-functions from another Thread, and that using signals & slots instead of plain function calling may fix the issue, but i have tried signals aswell, and i. karensantana. We have two classes in this example: DataGeneratorThread: is a QThread and is responsible for the actual data generation (generates random numbers according to a gaussian p. 1 Answer. OTOH, passing it by value in lambdas too is dangerous and can cause memory leaks. When data values are exchanged between QML and C++, they are converted by the QML engine to have the correct data types as appropriate for use in QML or C++. 2. ) The form here shows the exactly same problem but I can't use signal and slot as. qRegisterMetaType<QAbstractSocket::SocketState>(); Share. qRegisterMetaType<QSqlDatabase>("QSqlDatabase"); Just changing the signal to this form: void dbConnected(QSqlDatabase *db); And, in the slot side I'll use something like this: void onDBConnected(QSqlDatabase * const db); I'm concerned with the usage of db (as in the beginning I've made the reference const), so I make it const here (in the slot. Now it works fine when pressButtonInsert is triggered but returns this. Just installing it did not work for me. ; Create a native socket descriptor, instantiate QAbstractSocket, and call setSocketDescriptor() to wrap the native socket. if the permission has been granted, it continues with the next permission in the list. This results in access violations. I'm writing python library for very simple text output to Qt's QTextBrowser window (stored in window. This topic has been deleted. I tested your code on Qt 5. If you are using queued connections, you need to register std::string as meta type. It provides functions for creating and manipulating selections, and selecting a range of items from a model. Hey Something I wanted to follow up as I noticed I'm not the only with the issue. I'm getting this message in the application output pane in Qt Creator running Qt 5. Not sure yet. And it doesn't make a lot of sense that this particular API will have a. You can connect a signal to a slot with connect () and destroy the connection with disconnect () . Nope, registering with qRegisterMetaType<std::vector<int>>() has same effect as not registering at all (using QVector<int> works without registration, but does not expose length, either). QObject::connect: Cannot queue arguments of type 'CComPtr<IDeckLinkVideoFrame>' (Make sure 'CComPtr<IDeckLinkVideoFrame>' is registered using qRegisterMetaType(). flush ( self) This function writes as much as possible from the internal write buffer to the socket, without blocking. So I played around, copied the original macro and adapted it a bit: @. Please visit robotics. That is, only Predefined C++ Types and custom objects that have Q_PROPERTY declarations could access from QML environment. I can confirm the observed behaviour. (Make sure 'QVector<QVector<int> >' is registered using qRegisterMetaType (). In general, you only need Q_DECLARE_METATYPE (). Hi, you can try using a more robust flavor of connect() by adding an argument after the lambda, like this: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. QChildEvent. Here my test code and example: #include <QCoreApplication> #include <QDebug> #include <QMetaType> #include <QRect> #include <QMetaObject> class. if the permission was not granted or has been changed to NOT granted, the user is asked to grant permission. Note that if you intend to use the type in queued. Nov 30, 2012 at 8:31. But this is all useless if you are not using templates. The only changes were made to initArgs and appendArgs functions. 0, so Q_ENUM is my variant. step self. Got a similar example working without explicitly calling qRegisterMetaType() just by removing the semicolon from the line Q_DECLARE_METATYPE(StateMachine::state) – user666412. When you think about, there are quite convincing reasons to disallow it implicitly happening. 使用此连接类型在同一线程中的对象之间进行. qRe terMetaType 是Qt框架中的一个函数,用于在Qt元对象系统中注册自定义的数据类型。. Notice that with this approach you will only be able to check the value of the passed. 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. QObject::connect: Cannot queue arguments of type 'MyStruct'. QObject is the heart of the Qt Object Model. This function was introduced in Qt 5. I'm not sure how to do this in python but probably you should add similar call with QTextCursor. Share. As soon as the first event arrives I got the errormessage: @QObject::connect: Cannot queue arguments of type 'QQuickChangeSet'. ) What I'm trying to do is send a signal containing two cv::Mat images from a QThread to the main thread, so that I can display the output. 1、自定MyDataType 类型,在这个类型的顶部包含:#include <QMetaType>. 报错提示. 我们知道类中的成员函数并不一定会被调用(即,该宏并不确保类型被注册到MetaType)。 通过qRegisterMetaType可以确保类型被注册 ; 两个qRegisterMetaType 的联系QObject::connect: Cannot queue arguments of type 'QHostAddress' (Make sure 'QHostAddress' is registered using qRegisterMetaType(). Call qRegisterMetaType() to make types available to non-template based functions, such as the queued signal and slot connections.