C++ Case Switch with Fallthrough

By Brendan

According to the Qt Coding Style, you should include Q_FALLTHROUGH() for any switch clause that doesn’t have a break.

switch (myEnum) {
case Value1:
  doSomething();
  break;
case Value2:
case Value3:
  doSomethingElse();
  Q_FALLTHROUGH();
default:
  defaultHandling();
  break;
}

… unless there is no code at all, between two case labels, like with case Value2 and case Value3 in this example.