[Interest] MOC and QT_VERSION_CHECK bug??

Carel Combrink carel.combrink at gmail.com
Fri Aug 23 14:26:44 CEST 2013


(This message is a repost of a question asked on the forum, found
here<http://qt-project.org/forums/viewthread/31641/#139475>
)

Hi,

I am trying to get code to compile with both Qt 4 and Qt 5 bit it seems
like MOC in Qt 4 (or qmake) does not understand QT_VERSION_CHECK and I get
some strange outputs in the MOC file.

I am trying to implement different slots based on the Qt version. It looks
like it should be able to work, but without using QT_VERSION_CHECK.

See below my code for explanation:
My header file, part of a class

   1. // header file
   2. public slots:
   3. #if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
   4.     void slot_version_check_5() {}
   5. #endif
   6. #if QT_VERSION >= 0x050000
   7.     void slot_version_raw_5() {}
   8. #endif
   9. #if QT_VERSION < QT_VERSION_CHECK(5,0,0)
   10.     void slot_version_check_4() {}
   11. #endif
   12. #if QT_VERSION < 0x050000
   13.     void slot_version_raw_4() {}
   14. #endif

If I run qmake I get the following in my moc_*.cpp file:
Using Qt 4.8.1 or 4.8.5

   1.         switch (_id) {
   2.         case 0: _t->slot_version_check_5(); break;
   3.         case 1: _t->slot_version_raw_4(); break;
   4.         default: ;
   5.         }

Qt 5 yields:

   1.         switch (_id) {
   2.         case 0: _t->slot_version_check_5(); break;
   3.         case 1: _t->slot_version_raw_5(); break;
   4.         default: ;
   5.         }

As one can see, Qt 5 does the correct thing, while Qt 4 clearly does not.
(5 compiles, 4 does not)

I did look if I could find a bug for this in Qt 4. Is this a known bug or
limitation?

Update: As suggested I did look at the bugreports but could not find any
bug related to this.

Regards,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20130823/0c57a3af/attachment.html>


More information about the Interest mailing list