qtbase/tests/auto/tools/moc/flags-property-integer-access.h
Thiago Macieira c1b13a0c5f moc: add a test for Q_FLAG getter/setter on integers
This is legacy behavior from Qt 3, before we had QFlags and before
QVariant could support user types. I cannot find any instance of a
getter returning an integer in current Qt or Qt Creator code. And note
this only compiles if the flags type with Q_FLAG - not Q_ENUM.

The content is wrapped as Qt 6.x only so it can be removed in Qt
7.0. The deprecation warning will come in a later commit, for 6.9.

Change-Id: Ie3ddd8025e3b4387866efffd8e8d46c3daa0dff2
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
(cherry picked from commit 939f7f56227e65c9797d17640a7b9c29166efc44)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-09-24 20:30:14 +00:00

24 lines
600 B
C++

// Copyright (C) 2024 Intel Corporation.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#ifndef FLAGS_PROPERTY_INTEGER_ACCESS
#define FLAGS_PROPERTY_INTEGER_ACCESS
#include <QtCore/qobject.h>
class ClassWithFlagsAccessAsInteger : public QObject
{
Q_OBJECT
public:
enum Flag { F1 = 1, F2 = 2 };
Q_DECLARE_FLAGS(Flags, Flag)
Q_FLAG(Flags)
Q_PROPERTY(Flags flagsValue READ flagsValue WRITE setFlagsValue)
uint flagsValue() const { return f; }
void setFlagsValue(uint v) { f = v; }
private:
uint f = 0;
};
#endif // FLAGS_PROPERTY_INTEGER_ACCESS