Enum Sequence
-
wrote on 3 May 2015, 13:09 last edited by Sebastian 5 Mar 2015, 13:41
Dear All,
suppose I have Qflags. I want to know in which sequence the enum value is added.for eg.
class MyClass: public QObject
{
Q_OBJECTpublic:
explicit MyClass(QObject *parent = 0);
~MyClass();enum Sequence{ one = 1, two = 2, three = 3 }; Q_DECLARE_FLAGS(NumSequence, Sequence) NumSequence m_Flag; void setFlag(NumSequence &value) { m_Flag= value; }
};
Q_DECLARE_OPERATORS_FOR_FLAGS(MyClass::NumSequence)Eg: MyClass myClassObj;
myClassObj.setFlag(MyClass::three || MyClass::one );In this example my code should give me that MyClass::three was the first value.
-
Hi and welcome to devnet,
Your enum declaration is wrong if you want to create flags from it.
enum Sequence{ one = 0x01, two = 0x02, three = 0x04 };
3 being 11 in base 2, it would been that you have both one and two set
-
wrote on 5 May 2015, 06:54 last edited by
@Sebastian said:
nt to know in which sequence the enum value is added.for eg.
class MyClass: public QObjectthanks for your reply.
but i want to know the sequence of enum is added.for the above example how should i know that MyClass::three was the first value was the first value of mine.........and after that MyClass::one was the second value ...???(I want to know the sequence).thanks again @SGaist
-
Then you're using the wrong tool, flags don't have any notion of input order. If you want a FIFO behavior you should rather use a container like QQueue
1/4