Hello everyone,
I want to use a custom data type with QVariant, specifically I want to push_back a "Vector3" class instance onto a QVector<QVariant>. I already searched the forums and found some helpful information ( for example http://www.qtcentre.org/forum/f-qt-p...types-146.html ), but somehow it doesn´t work the way it should.

my "Vector3" class:
Qt Code:
  1. #ifndef __VECTOR3_H_
  2. #define __VECTOR3_H_
  3.  
  4. #include <QMetaType>
  5.  
  6. class Vector3
  7. {
  8.  
  9. public:
  10. Vector3(): x(0), y(0), z(0) {};
  11.  
  12. Vector3(float inX, float inY , float inZ) : x (inX), y (inY), z (inZ) {};
  13.  
  14.  
  15. Vector3::Vector3(const Vector3 &vector3) {
  16. x=vector3.getX();
  17. y=vector3.getY();
  18. z=vector3.getZ();
  19. }
  20.  
  21. [...]
  22.  
  23. private:
  24. float x;
  25. float y;
  26. float z;
  27.  
  28. };
  29.  
  30. Q_DECLARE_METATYPE(Vector3);
  31.  
  32. #endif //__VECTOR3_H_
To copy to clipboard, switch view to plain text mode 

I try to use it that way (parameters is: QVector<QVariant> parameters; ):
Qt Code:
  1. Vector3 test;
  2. parameters.push_back(test);
To copy to clipboard, switch view to plain text mode 

Which results in the following:
.\view\Drawing.cpp(20) : error C2664: 'QVector<T>:ush_back' : cannot convert parameter 1 from 'Vector3' to 'const QVariant &'
with
[
T=QVariant
]
Reason: cannot convert from 'Vector3' to 'const QVariant'
No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
Now my naive understanding was that I´d only have to Q_DECLARE_METATYPE(Vector3) and everything would work, but that´s obviously wrong. A few pointers in the right direction would be greatly appreciated.