[Development] API style guide: scoped enum or not?

Sune Vuorela nospam at vuorela.dk
Thu May 4 15:51:24 CEST 2023

On 2023-05-04, Marc Mutz via Development <development at qt-project.org> wrote:
> that keeps unported code running. The main issue isn't the scoping, the 
> main issue will be the missing implicit conversion to underlying_type.

In few cases the implicit conversion to underlying_type is kind of important.

Especially in the cases where the api has int and is mostly used with
enums or is somehow user extendable.

Qt::ItemDataRole is one of them that comes to mind.

switch(role) {
   case Qt::UserRole+1:

QEvent::Type is another one where one registerEventType, recieves an int
and then force-cast it to QEvent::Type and still compares back to that
int in other places.

There are definitely more.


More information about the Development mailing list