[Development] QKeySequenceEdit: Unable to assign tab

Thiago Macieira thiago.macieira at intel.com
Fri Jun 24 20:52:44 CEST 2022


On Friday, 24 June 2022 11:31:22 PDT Kai Uwe Broulik wrote:
> Hi,
> 
> you cannot reply rely on RTTI in Qt Core. static_cast is fine in this
> scenario as we know it'll be a key event.

I don't remember any more what we did in Qt 5, but in Qt 6 RTTI is always 
enabled. And yet we don't use it directly and in this case you're right: 
confirm the event type and do a static_cast.

This also violates the First Rule of Dynamic Cast:

+    case QEvent::KeyPress:
+        keyPressEvent(dynamic_cast<QKeyEvent *>(e));
+        return true;

ALL[*] dynamic_cast must be checked for returning null and handled properly, 
with something other than a warning (or worse).

[*] there's an exception to this rule. Exercise left to the reader to find out 
what it is.

-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Cloud Software Architect - Intel DCAI Cloud Engineering





More information about the Development mailing list