Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. MOC and QT_VERSION_CHECK bug??
Forum Updated to NodeBB v4.3 + New Features

MOC and QT_VERSION_CHECK bug??

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 2.2k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • TheBadgerT Offline
    TheBadgerT Offline
    TheBadger
    wrote on last edited by
    #1

    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,


    Check out my SpellChecker Plugin for Qt Creator @ https://github.com/CJCombrink/SpellChecker-Plugin

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      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

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved