[Development] Proposing to change https://wiki.qt.io/API_Design_Principles#Enums_in_classes to require scoped enums

Marco Bubke marco.bubke at qt.io
Sat Jan 18 00:12:36 CET 2025


Hi

On 16.01.25 11:58, Marc Mutz via Development wrote:
> Hi,
> 
> Groundhog Day...
> 
> Like every API review, so also in 6.9, we have the discussions between
> proponents of scoped vs. unscoped enums in class scope.

One little side note. Putting enumerations into classes can introduce a 
dependency. Using them in mocks is much harder because there are easily 
hard linking dependencies on the library and not only a header file with 
the enumerations.

So what about moving them out of the class into an extra header file?

Like

TouchPoint::Pressed -> Touch::Pressed

enum class  Touch : int {
   Pressed,
   ...
};

They than could be forward declared too.


More information about the Development mailing list