Questions tagged [qenum]
4 questions
4
votes
2 answers
How to access a Q_ENUM declared in C++ class from QML?
I have a Q_ENUM declared in MyClass like below:
class MyClass {
public:
enum Enum_Test {
eTestA,
eTestB
}
Q_ENUM(Enum_Test)
Q_OBJECT
Q_PROPERTY(MyClass::Enum_Test enumTest READ GetEnumTest WRITE SetEnumTest…

TheWaterProgrammer
- 7,055
- 12
- 70
- 159
1
vote
1 answer
How to properly compare Q_ENUM and QStringList
I have a small example .ui where the user can drag and drop from a QListWidget to a QGraphicsView using QGraphicsProxyWidget a specific widget (in my case is a QTableWidget) as shown below.
Basically the behavior I have been looking for is:
If I…

Emanuele
- 2,194
- 6
- 32
- 71
0
votes
1 answer
Qt How to register enum class in QML without QObject class
EnumClasses.h
#ifndef ENUMCLASSES_H
#define ENUMCLASSES_H
#include
namespace mynamespace {
enum class Fruit : int
{
Apple,
Banana,
Orange
};
Q_ENUM(Fruit)
}
…

Евгений Дружинин
- 263
- 1
- 4
- 10
0
votes
1 answer
How to test if a value is valid for a QFlags
Let's say I have this flag:
enum MyEnum
{
AAA = 1,
BBB = 2,
CCC = 4,
DDD = 8
};
Q_DECLARE_FLAGS( MyFlags, MyEnum )
Q_FLAG( MyFlags )
How can I test if a value is valid?
i.e. I'd expected -1 or 16 to be invalid.
For enum, this can be…

Denis Rouzaud
- 2,412
- 2
- 26
- 45