[Qt-interest] QFlags and conditional assignment
Ulf-Alexander v. Ceumern-Lindenstjerna
ceumern at vrmagic.com
Thu Feb 25 12:30:57 CET 2010
Hi list,
while testing my own QFlags for the first time I found a strange compiler issue:
this is the class using the flags:
MyClass{
enum ScoringOption {
SCORING_DISABLED = 0x0,
SCORING_FUNDUS = 0x1,
...
};
Q_DECLARE_FLAGS(ScoringOptions, ScoringOption)
private:
ScoringOptions m_scoringOptions;
}
Q_DECLARE_OPERATORS_FOR_FLAGS(MyClass::ScoringOptions)
This is what I do:
m_scoringOptions = 0; // works!
bool ok = true;
m_scoringOptions = ok ? SCORING_FUNDUS : SCORING_DISABLED; //works!
m_scoringOptions = ok ? SCORING_FUNDUS : 0; // error:
1>.\src\myclass.cpp(150) : error C2679: binary '=' : no operator found which takes a right-hand operand of type 'int' (or there is no acceptable conversion)
1> d:\lib\qt\4.6.1\include\qtcore\../../src/corelib/global/qglobal.h(2172): could be 'QFlags<Enum> &QFlags<Enum>::operator =(const QFlags<Enum> &)'
1> with
1> [
1> Enum= MyClass::ScoringOption
1> ]
1> while trying to match the argument list '(MyClass::ScoringOptions, int)'
Apparently the assignment operator behaves differently when a conditional assignment is used. Is this intended? Or am I doing something horribly wrong?
I am puzzled...
Regards, Ulf
--
Ulf v. Ceumern
Dipl.-Inf.
VRmagic GmbH
Augustaanlage 32
68165 Mannheim, Germany
E-Mail: ceumern at vrmagic.com
Tel.: +49/621/400416-52
Fax: +49/621/400416-99
Steuernummer: 38189/54003
USt.IdNr.: DE217365947
Registergericht: Amtsgericht Mannheim, HRB 8958
Geschäftsführer: Norbert Hinckers, Dr. Markus Schill
--
More information about the Qt-interest-old
mailing list