PDA

View Full Version : Strange error message while using Q_ASSERT



homerun4711
11th January 2011, 09:06
Hello!

I get a strange error message while compiling my project, it was working fine until I re-created the *.project file and the user-file from OtDesigner.

The error message is



error: no match for ‘operator!’ in ‘!record’
candidates are: operator!(bool) <built-in>


and points to the Q_ASSERT in the following code



QSqlRecord record = customerSelect->passRecord();
Q_ASSERT(record);


If I comment the Q_ASSERT line everything works fine. Has someone an idea what is causing this error?

Kind regards,
HomeR

stampede
11th January 2011, 13:08
Error message explains everything, you can't use operator ! on QSqlRecord objects.
This operator is used in Q_ASSERT macro:

#define Q_ASSERT(cond) ((!(cond)) ? qt_assert(#cond,__FILE__,__LINE__) : qt_noop())
So in your case this expands to:

...!(record)...
I think you mean something like:

Q_ASSERT( ! record.isEmpty() )

homerun4711
11th January 2011, 14:34
Thank you for the answer. This explains everything, I was not aware of how Q_ASSERT is working behind the curtain.