MOC and QT_VERSION_CHECK bug??



  • 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
    @
    // header file
    public slots:
    #if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
    void slot_version_check_5() {}
    #endif
    #if QT_VERSION >= 0x050000
    void slot_version_raw_5() {}
    #endif
    #if QT_VERSION < QT_VERSION_CHECK(5,0,0)
    void slot_version_check_4() {}
    #endif
    #if QT_VERSION < 0x050000
    void slot_version_raw_4() {}
    #endif
    @

    If I run qmake I get the following in my moc_*.cpp file:
    Using Qt 4.8.1 or 4.8.5
    @
    switch (_id) {
    case 0: _t->slot_version_check_5(); break;
    case 1: _t->slot_version_raw_4(); break;
    default: ;
    }
    @

    Qt 5 yields:
    @
    switch (_id) {
    case 0: _t->slot_version_check_5(); break;
    case 1: _t->slot_version_raw_5(); break;
    default: ;
    }
    @

    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?

    Regards,


  • Lifetime Qt Champion

    Hi,

    This is a good question and might very well be a bug. I would recommend you forward it to the interest mailing list, you'll find there Qt's developers/maintainers (this forum is more user oriented)

    Maybe also check the "but report system":http://bugreports.qt-project.org/issues/ to see if it's something known


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.