my problem is the following : i want ot use a drag and drop in my Qtreewidget, my QtreeWidgetItem are : Enabled | selectable |Drag | Drop. it work for an item but don't for the rest (Error Qvariant::Save invalid type to save)
it's because we do some : setdata(QVariant::fromvalue<... i understand since i want to use custom data i need to make QVariant understand my class, and for this i need my class to have a default constructor, a copy constructor , a destructor, and 2 operator overlord << et >> friend QDataStream & operator << (QDataStream &arch, const MyClass & object)
After i need Q_DECLARE_METATYPE(MyClass) and register my operator with : qRegisterMetaTypeStreamOperators("MyClass")
But i can't get it work. (still Error Qvariant::Save invalid type to save)
I need help to understand where everything goes. My overloads operators are defined in my class (.H)
Should my Q_DECLARE_METATYPE be declared at the end of my class? (.h) will there be problem because somme class herit from it? or because it have pure functiun?
I know many people use the qRegisterMetaTypeStreamOperators in the main but i can't do that, can i use it elsewhere (in the constructor of one my class or this will cause problem (like multiple declaration or multiple call like the connect functiun))
The error never change , is this normal or should qt say to me "he recognise the class i want to save but he don't everything needed"?
thanks a lot for your future answer :)
Aucun commentaire:
Enregistrer un commentaire