Created
March 28, 2016 14:47
-
-
Save 0xlitf/741d0a47267ce197ebb3 to your computer and use it in GitHub Desktop.
Qt信号槽传递std::tuple
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| typedef std::tuple<QString, QString, QString, QString, QString, | |
| QString, QString, QString, QString, QImage> | |
| PersonInfo; | |
| qRegisterMetaType<PersonInfo>("PersonInfo"); | |
| Q_DECLARE_METATYPE( Type) //使自定义类型可以存进QVarient | |
| This macro makes the type Type known to QMetaType as long as it provides a public default constructor, a public copy constructor and a public destructor. It is needed to use the type Type as a custom type in QVariant. | |
| This macro requires that Type is a fully defined type at the point where it is used. For pointer types, it also requires that the pointed to type is fully defined. Use in conjunction with Q_DECLARE_OPAQUE_POINTER() to register pointers to forward declared types. | |
| Ideally, this macro should be placed below the declaration of the class or struct. If that is not possible, it can be put in a private header file which has to be included every time that type is used in a QVariant. | |
| Adding a Q_DECLARE_METATYPE() makes the type known to all template based functions, including QVariant. 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. | |
| This example shows a typical use case of Q_DECLARE_METATYPE(): |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment