Results 1 to 3 of 3

Thread: Strange error message while using Q_ASSERT

  1. #1
    Join Date
    Oct 2010
    Posts
    91
    Thanks
    38

    Default Strange error message while using Q_ASSERT

    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

    Qt Code:
    1. QSqlRecord record = customerSelect->passRecord();
    2. Q_ASSERT(record);
    To copy to clipboard, switch view to plain text mode 

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

    Kind regards,
    HomeR

  2. #2
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,394
    Thanked 342 Times in 324 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Strange error message while using Q_ASSERT

    Error message explains everything, you can't use operator ! on QSqlRecord objects.
    This operator is used in Q_ASSERT macro:
    Qt Code:
    1. #define Q_ASSERT(cond) ((!(cond)) ? qt_assert(#cond,__FILE__,__LINE__) : qt_noop())
    To copy to clipboard, switch view to plain text mode 
    So in your case this expands to:
    Qt Code:
    1. ...!(record)...
    To copy to clipboard, switch view to plain text mode 
    I think you mean something like:
    Qt Code:
    1. Q_ASSERT( ! record.isEmpty() )
    To copy to clipboard, switch view to plain text mode 
    Last edited by stampede; 11th January 2011 at 13:13. Reason: wrong class name

  3. The following user says thank you to stampede for this useful post:

    homerun4711 (11th January 2011)

  4. #3
    Join Date
    Oct 2010
    Posts
    91
    Thanks
    38

    Default Re: Strange error message while using Q_ASSERT

    Thank you for the answer. This explains everything, I was not aware of how Q_ASSERT is working behind the curtain.

Similar Threads

  1. QPrinter strange message
    By laszlo.gosztola in forum Qt Programming
    Replies: 0
    Last Post: 9th December 2010, 08:40
  2. any way to catch error message from dll in a gui app?
    By lvdong in forum Qt Programming
    Replies: 2
    Last Post: 24th October 2010, 10:49
  3. How to break in debugger in Q_ASSERT ?
    By Radagast in forum Qt Programming
    Replies: 3
    Last Post: 24th May 2010, 13:42
  4. error message
    By offline in forum Qt Programming
    Replies: 1
    Last Post: 5th November 2009, 14:08
  5. what`s means this Error Message?
    By blm in forum Qt Programming
    Replies: 2
    Last Post: 15th September 2008, 16:58

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.