Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-86404

Defintion of QT_NO_DEPRECATED causes compile errors

    XMLWordPrintable

Details

    • Suggestion
    • Resolution: Out of scope
    • Not Evaluated
    • None
    • 5.15.0
    • Core: Object Model
    • None

    Description

      I tried today to compile our framework with Qt6 Alpha. There I got tons of compile issues as we still using deprecated classes, which are not marked as deprecated via `[[deprecated]]` (we have our compilers configured with warnings as errors). To remove all legacy code I tried to `add_definitions(-DQT_NO_DEPRECATED=1)` to our CMake code, but this isn't working as using `Q_OBJECT` includes code which is maked with the macro `QT_DEPRECATED`, which will be explicitly unset.

      Therefore I'm getting compile errors like (Clang 10):

      In file included from /home/sunblack/dev/dependencies/Qt/5.15.0/gcc_64/include/QtWidgets/QDialog:1:
      In file included from /home/sunblack/dev/dependencies/Qt/5.15.0/gcc_64/include/QtWidgets/qdialog.h:44:
      In file included from /home/sunblack/dev/dependencies/Qt/5.15.0/gcc_64/include/QtWidgets/qwidget.h:45:
      /home/sunblack/dev/dependencies/Qt/5.15.0/gcc_64/include/QtCore/qobject.h:129:5: error: unknown type name 'QT_DEPRECATED'
          Q_OBJECT
          ^
      /home/sunblack/dev/dependencies/Qt/5.15.0/gcc_64/include/QtCore/qobjectdefs.h:178:5: note: expanded from macro 'Q_OBJECT'
          QT_TR_FUNCTIONS \
          ^
      /home/sunblack/dev/dependencies/Qt/5.15.0/gcc_64/include/QtCore/qobjectdefs.h:134:5: note: expanded from macro 'QT_TR_FUNCTIONS'
          QT_DEPRECATED static inline QString trUtf8(const char *s, const char *c = nullptr, int n = -1) \
          ^
      

      Same with MSVC. Is there a workaround to disable all deprecated code, except `add_definitions(-DQT_DISABLE_DEPRECATED_BEFORE=0x050F00)`?

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            thiago Thiago Macieira
            EliteScience Heiko Thiel
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes