Qt-WrongQEventCast¶
When static_casting a QEvent, cast to the correct type
Required inputs: IR
Example:
switch (ev->type()) {
case QEvent::MouseMove:
auto e = static_cast<QKeyEvent*>(ev);
}
Only casts inside switch statements are verified.This rule is based on clazy rule wrong-qevent-cast
Possible Messages
Key |
Text |
Severity |
Disabled |
|---|---|---|---|
wrong_qevent_cast |
Cast from a QEvent::{} event to {} looks suspicious. |
None |
False |
Options¶
This rule shares the following common options: exclude_in_macros, exclude_messages_in_system_headers, excludes, extend_exclude_to_macro_invocations, includes, justification_checker, languages, post_processing, provider, report_at, severity
The following places define options that affect this rule: Stylechecks, Analysis-GlobalOptions
level¶
level : int = 0
unregularly_named_event_types¶
unregularly_named_event_types
A mapping from event codes to a list of event classes to which an event using this code can be cast. Only needed for mappings that do not follow the obvious standard naming scheme.Type: dict[str, list[str]]
Default:
{ 'ActionAdded': ['QActionEvent'], 'ActionChanged': ['QActionEvent'], 'ActionRemoved': ['QActionEvent'], 'ChildAdded': ['QChildEvent'], 'ChildPolished': ['QChildEvent'], 'ChildRemoved': ['QChildEvent'], 'ContextMenu': ['QInputEvent'], 'DragEnter': ['QDragEnterEvent', 'QDragMoveEvent', 'QDropEvent'], 'DragLeave': ['QDragLeaveEvent', 'QDragMoveEvent', 'QDropEvent'], 'DragMove': ['QDragMoveEvent', 'QDropEvent'], 'FocusAboutToChange': ['QFocusEvent'], 'FocusIn': ['QFocusEvent'], 'FocusOut': ['QFocusEvent'], 'Gesture': ['QGestureEvent'], 'GestureOverride': ['QGestureEvent'], 'GraphicsSceneContextMenu': ['QGraphicsSceneEvent'], 'GraphicsSceneDragEnter': ['QGraphicsSceneDragDropEvent', 'QGraphicsSceneEvent'], 'GraphicsSceneDragLeave': ['QGraphicsSceneDragDropEvent', 'QGraphicsSceneEvent'], 'GraphicsSceneDragMove': ['QGraphicsSceneDragDropEvent', 'QGraphicsSceneEvent'], 'GraphicsSceneDrop': ['QGraphicsSceneDragDropEvent', 'QGraphicsSceneEvent'], 'GraphicsSceneHelp': ['QGraphicsSceneEvent'], 'GraphicsSceneHoverEnter': ['QGraphicsSceneHoverEvent', 'QGraphicsSceneEvent'], 'GraphicsSceneHoverLeave': ['QGraphicsSceneHoverEvent', 'QGraphicsSceneEvent'], 'GraphicsSceneHoverMove': ['QGraphicsSceneHoverEvent', 'QGraphicsSceneEvent'], 'GraphicsSceneMouseDoubleClick': ['QGraphicsSceneMouseEvent'], 'GraphicsSceneMouseMove': ['QGraphicsSceneMouseEvent'], 'GraphicsSceneMousePress': ['QGraphicsSceneMouseEvent'], 'GraphicsSceneMouseRelease': ['QGraphicsSceneMouseEvent'], 'GraphicsSceneResize': ['QGraphicsSceneEvent'], 'GraphicsSceneWheel': ['QGraphicsSceneEvent'], 'HoverEnter': ['QHoverEvent', 'QInputEvent'], 'HoverLeave': ['QHoverEvent', 'QInputEvent'], 'HoverMove': ['QHoverEvent', 'QInputEvent'], 'KeyPress': ['QKeyEvent', 'QInputEvent'], 'KeyRelease': ['QKeyEvent', 'QInputEvent'], 'MetaCall': ['QDBusSpyCallEvent', 'QDBusCallDeliveryEvent'], 'MouseButtonDblClick': ['QMouseEvent'], 'MouseButtonPress': ['QMouseEvent'], 'MouseButtonRelease': ['QMouseEvent'], 'MouseMove': ['QMouseEvent'], 'NativeGesture': ['QInputEvent'], 'NonClientAreaMouseButtonDblClick': ['QMouseEvent'], 'NonClientAreaMouseButtonPress': ['QMouseEvent'], 'NonClientAreaMouseButtonRelease': ['QMouseEvent'], 'NonClientAreaMouseMove': ['QMouseEvent'], 'OrientationChange': ['QScreenOrientationChangeEvent'], 'QueryWhatsThis': ['QHelpEvent'], 'ShortcutOverride': ['QKeyEvent', 'QInputEvent'], 'TabletEnterProximity': ['QTabletEvent', 'QInputEvent'], 'TabletLeaveProximity': ['QTabletEvent', 'QInputEvent'], 'TabletMove': ['QTabletEvent', 'QInputEvent'], 'TabletPress': ['QTabletEvent', 'QInputEvent'], 'TabletRelease': ['QTabletEvent', 'QInputEvent'], 'ToolTip': ['QHelpEvent'], 'TouchBegin': ['QTouchEvent', 'QInputEvent'], 'TouchCancel': ['QTouchEvent', 'QInputEvent'], 'TouchEnd': ['QTouchEvent', 'QInputEvent'], 'TouchUpdate': ['QTouchEvent', 'QInputEvent'], 'WhatsThis': ['QHelpEvent'], 'Wheel': ['QInputEvent'] }