Changing class local enum to enum class
-
I have a class:
class QLinearGradientCtrl : public QWidget { Q_OBJECT Q_PROPERTY(QLinearGradient gradient READ gradient WRITE setGradient) Q_PROPERTY(int gradientWidth READ orientation WRITE setGradientWidth) Q_PROPERTY(Orientation orientation READ orientation WRITE setOrientation) public: enum Orientation { ForceHorizontal, ForceVertical, Auto };
I changed the enum to enum class Orientation, but that gave me:
moc_QLinearGradientCtrl.cpp 1>C:\Users\amonra\Documents\GitHub\DSS\DeepSkyStacker\GeneratedFiles\moc_QLinearGradientCtrl.cpp(199,65): error C2440: '=': cannot convert from 'QLinearGradientCtrl::Orientation' to 'int'
What do I need to do to get this working?
-
@Perdrix What's at line 199 in moc_QLinearGradientCtrl.cpp? What is the signature of orientation and setOrientation methods?
-
Line 199:
case 1: *reinterpret_cast< int*>(_v) = _t->orientation(); break;
Function sigs:
Orientation orientation() const { return m_Orientation; }; QLinearGradientCtrl & setOrientation(Orientation orientation) { m_Orientation = orientation; return *this; };
Thanks
David -
@Perdrix
I know nothing aboutQ_PROPERTY
s. But since yourorientation()
returns anOrientation
then as per the error message:'=': cannot convert from 'QLinearGradientCtrl::Orientation' to 'int'
if you assign to
* <int *>
that is anint
, won't you need to cast/convertOrientation
toint
for that to be acceptable to compiler? -
@Perdrix said in Changing class local enum to enum class:
Arrggghhhh! Classic copy/paste error
Mea maxima culpa :(
D.
Been there, done that, won the swearing contest :-)