Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
QTreeWidgetItem 内に QVariant オブジェクトがあります。それを自分のオブジェクトにキャストするにはどうすればよいですか?
.hファイルのどこかで次のように宣言する必要があります。
.h
Q_DECLARE_METATYPE(MyStruct)
そして、あなたはただ使うことができます:
MyStruct s; QVariant var; var.setValue(s); // copy s into the variant // retrieve the value MyStruct s2 = var.value<MyStruct>();
こちらのドキュメントをご覧ください