I am looking at this Qt's example from the doc http://doc.qt.io/qt-5/statemachine-api.html :
bool eventTest(QEvent *e) override
{
if (e->type() != QEvent::Type(QEvent::User+1)) // StringEvent
return false;
StringEvent *se = static_cast<StringEvent*>(e);
return (m_value == se->value);
}
But in the line :
e->type() != QEvent::Type(QEvent::User+1)
I do not understand the need for an explicit cast here, that is the integer value to enum Event::Type
because the following also works :
e->type() != QEvent::User+1 // no explicit cast
So is it better to use an explicit cast and why ?
Thank you.