Casts for events
-
Hello,
Is there a special method for downcastingQEvents to more concrete types? I was thinking something likeqobject_castandqgraphicsitem_cast? Should I simply stick todynamic_castinstead?Thanks!
-
Qt uses
reinterpret_castandstatic_castmade safe by checkingQEvent::typeso I suppose that's the way to go@VRonin said in Casts for events:
Qt uses reinterpret_cast and static_cast made safe by checking QEvent::type so I suppose that's the way to go
Yes, this is what I do usually. The point is there are multiple event types that map to the same class, for example
QMouseEventandQHoverEvent. Meaning you have to check all possible types (i.e. a big switch) before doing the cast. But fair enough, if there isn't anything likeqobject_cast, there isn't.