File indexing completed on 2024-04-28 05:38:42
0001 #include <QtCore/QVariant> 0002 #include <QtCore/QUrl> 0003 0004 0005 enum Foo { 0006 Foo1 0007 }; 0008 Q_DECLARE_METATYPE(Foo) 0009 0010 0011 void test() 0012 { 0013 QHash<QString, QVariant> properties; 0014 properties.insert("name", "John Doe"); 0015 properties.insert("age", 42); 0016 properties.value("name").toString(); //Ok 0017 properties["age"].value<int>(); //Warn 0018 0019 properties["name"].value<Foo>(); //Ok 0020 }