diff options
author | Andre Somers <andre.somers@kdab.com> | 2016-02-02 10:16:24 +0100 |
---|---|---|
committer | Andre Somers <andre@familiesomers.nl> | 2016-02-08 10:25:09 +0000 |
commit | 21861e6fd1fcd1e4642f3d4c06ee7181d2c81778 (patch) | |
tree | 77ef4099210c4ba1b05dab5fd4e07aff8d7145e4 /tests/auto/corelib/global | |
parent | 74adb1900a7f6f219339bd4ed2a74b5816b63d64 (diff) |
Add setFlag method to QFlags
This makes implementing class methods that enable or disable a feature
stored in a QFlags<> member easier.
[ChangeLog][QtCore][QFlags] Added setFlag method to set or unset a flag
Task-number: QTBUG-27100
Change-Id: Ic602abbbf3100df78f21b7918573744d1bbd18c1
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Diffstat (limited to 'tests/auto/corelib/global')
-rw-r--r-- | tests/auto/corelib/global/qflags/tst_qflags.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/auto/corelib/global/qflags/tst_qflags.cpp b/tests/auto/corelib/global/qflags/tst_qflags.cpp index 3e1b60419d..10902b6f55 100644 --- a/tests/auto/corelib/global/qflags/tst_qflags.cpp +++ b/tests/auto/corelib/global/qflags/tst_qflags.cpp @@ -38,6 +38,7 @@ private slots: void signedness(); void classEnum(); void initializerLists(); + void testSetFlags(); }; void tst_QFlags::testFlag() const @@ -278,6 +279,19 @@ void tst_QFlags::initializerLists() #endif // Q_COMPILER_INITIALIZER_LISTS } +void tst_QFlags::testSetFlags() +{ + Qt::MouseButtons btn = Qt::NoButton; + + btn.setFlag(Qt::LeftButton); + QVERIFY(btn.testFlag(Qt::LeftButton)); + QVERIFY(!btn.testFlag(Qt::MidButton)); + + btn.setFlag(Qt::LeftButton, false); + QVERIFY(!btn.testFlag(Qt::LeftButton)); + QVERIFY(!btn.testFlag(Qt::MidButton)); +} + // (statically) check QTypeInfo for QFlags instantiations: enum MyEnum { Zero, One, Two, Four=4 }; Q_DECLARE_FLAGS( MyFlags, MyEnum ) |