Naming Convention
A sensible naming convention for enum types and associated QFlags types is to give a singular name to the enum type (e.g., Option) and a plural name to the QFlags type (e.g., Options). When a singular name is desired for the QFlags type (e.g., Alignment), you can use Flag as the suffix for the enum type (e.g., AlignmentFlag).
See also QFlag.
Member Type Documentation
typedef QFlags::enum_type
Typedef for the Enum template type.
Member Function Documentation
QFlags::QFlags ( const QFlags & other )
Constructs a copy of other.
QFlags::QFlags ( Enum flag )
Constructs a QFlags object storing the given flag.
QFlags::QFlags ( Zero zero = 0 )
Constructs a QFlags object with no flags set. zero must be a literal 0 value.
QFlags::QFlags ( QFlag value )
Constructs a QFlags object initialized with the given integer value.
The QFlag type is a helper type. By using it here instead of int, we effectively ensure that arbitrary enum values cannot be cast to a QFlags, whereas untyped enum values (i.e., int values) can.
bool QFlags::testFlag ( Enum flag ) const
Returns true if the flag is set, otherwise false.
This function was introduced in Qt 4.2.
QFlags::operator int () const
Returns the value stored in the QFlags object as an integer.
bool QFlags::operator! () const
Returns true if no flag is set (i.e., if the value stored by the QFlags object is 0); otherwise returns false.
QFlags QFlags::operator& ( int mask ) const
Returns a QFlags object containing the result of the bitwise AND operation on this object and mask.
See also operator&=(), operator|(), operator^(), and operator~().
QFlags QFlags::operator& ( uint mask ) const
This is an overloaded function.
QFlags QFlags::operator& ( Enum mask ) const
This is an overloaded function.
QFlags & QFlags::operator&= ( int mask )
Performs a bitwise AND operation with mask and stores the result in this QFlags object. Returns a reference to this object.
See also operator&(), operator|=(), and operator^=().
QFlags & QFlags::operator&= ( uint mask )
This is an overloaded function.
QFlags & QFlags::operator= ( const QFlags & other )
Assigns other to this object and returns a reference to this object.
QFlags QFlags::operator^ ( QFlags other ) const
Returns a QFlags object containing the result of the bitwise XOR operation on this object and other.
See also operator^=(), operator&(), operator|(), and operator~().
QFlags QFlags::operator^ ( Enum other ) const
This is an overloaded function.
QFlags & QFlags::operator^= ( QFlags other )
Performs a bitwise XOR operation with other and stores the result in this QFlags object. Returns a reference to this object.
See also operator^(), operator&=(), and operator|=().
QFlags & QFlags::operator^= ( Enum other )
This is an overloaded function.
QFlags QFlags::operator| ( QFlags other ) const
Returns a QFlags object containing the result of the bitwise OR operation on this object and other.
See also operator|=(), operator^(), operator&(), and operator~().
QFlags QFlags::operator| ( Enum other ) const
This is an overloaded function.
QFlags & QFlags::operator|= ( QFlags other )
Performs a bitwise OR operation with other and stores the result in this QFlags object. Returns a reference to this object.
See also operator|(), operator&=(), and operator^=().
QFlags & QFlags::operator|= ( Enum other )
This is an overloaded function.
QFlags QFlags::operator~ () const
Returns a QFlags object that contains the bitwise negation of this object.
See also operator&(), operator|(), and operator^().
Macro Documentation
Q_DECLARE_FLAGS ( Flags, Enum )
The Q_DECLARE_FLAGS() macro expands to
typedef QFlags<Enum> Flags;
Enum is the name of an existing enum type, whereas Flags is the name of the QFlags<Enum> typedef.
See the QFlags documentation for details.
See also Q_DECLARE_OPERATORS_FOR_FLAGS().
Q_DECLARE_OPERATORS_FOR_FLAGS ( Flags )
The Q_DECLARE_OPERATORS_FOR_FLAGS() macro declares global operator|() functions for Flags, which is of type QFlags<T>.
See the QFlags documentation for details.
See also Q_DECLARE_FLAGS().