Typos / weirdness in QFlags default arguments

David Faure faure at kde.org
Sun Aug 19 16:56:10 BST 2007


On Sunday 19 August 2007, Adriaan de Groot wrote:
> In kdelibs methods that take QFlags arguments with a default, like so (from 
> kdeui/):
> 
> void setShapeGesture(const KShapeGesture& gest, ShortcutTypes type = 
> static_cast<ShortcutType>(ActiveShortcut | DefaultShortcut));
> 
> there seem to be two things wrong: the static cast to ShortcutType instead of 
> ShortcutTypes and the fact that static cast is being used at all. Is there a 
> good reason to avoid
> 
> ShortcutTypes(ActiveShortcut | DefaultShortcut)
> 
> or
> 
> QFlags<ShortcutType>(ActiveShortcut) | QFlags<ShortcutType>(DefaultShortcut)

The operator| on this QFlags isn't defined yet where this method is defined,
that's the issue. It's defined after the class declaration.

But I think your first suggestion should be fine.

-- 
David Faure, faure at kde.org, sponsored by Trolltech to work on KDE,
Konqueror (http://www.konqueror.org), and KOffice (http://www.koffice.org).




More information about the kde-core-devel mailing list