diff --git a/QtQVariant/QtQVariant.pro b/QtQVariant/QtQVariant.pro new file mode 100644 index 0000000..197e5fc --- /dev/null +++ b/QtQVariant/QtQVariant.pro @@ -0,0 +1,16 @@ +QT -= gui + +CONFIG += c++11 console +CONFIG -= app_bundle + +# You can make your code fail to compile if it uses deprecated APIs. +# In order to do so, uncomment the following line. +#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 + +SOURCES += \ + main.cpp + +# Default rules for deployment. +qnx: target.path = /tmp/$${TARGET}/bin +else: unix:!android: target.path = /opt/$${TARGET}/bin +!isEmpty(target.path): INSTALLS += target diff --git a/QtQVariant/main.cpp b/QtQVariant/main.cpp new file mode 100644 index 0000000..2e54dec --- /dev/null +++ b/QtQVariant/main.cpp @@ -0,0 +1,29 @@ +#include +#include +using namespace std; + +class C{}; //自定义类型 +//Q_DECLARE_METATYPE(C) + +int main() +{ + QVariant v('a'); // QVariant 没有专门的 char 构造函数,此处的字符 a 会被转换为 int 型,因此 v中存储的是数值 97,而不是字符 a 。 + cout<()<()<