Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

[Solved] How to enable QT_DEPRECATED in Qt 5.4.0 build



  • Hi all,

    How do I enable the QT_DEPRECATED flag when I build Qt 5.4.0? I am trying to build zbar against Qt, but it uses deprecated members and functions.

    In file included from qt/QZBarThread.h:30:0,
                 from qt/QZBar.cpp:28:
    ./include/zbar/QZBarImage.h: In constructor ‘zbar::QZBarImage::QZBarImage(const QImage&)’:
    ./include/zbar/QZBarImage.h:57:38: error: ‘const class QImage’ has no member named ‘numBytes’
         unsigned long datalen = qimg.numBytes();
                                      ^
    qt/QZBar.cpp: In constructor ‘zbar::QZBar::QZBar(QWidget*)’:
    qt/QZBar.cpp:52:39: error: ‘x11Info’ was not declared in this scope
         thread->window.attach(x11Info().display(), winId());
                                       ^
    ...
    

    QtGui/qimage.h:

    ...
    #if QT_DEPRECATED_SINCE(5, 0)
        QT_DEPRECATED inline int numColors() const;
        QT_DEPRECATED inline void setNumColors(int);
        QT_DEPRECATED inline int numBytes() const;
    #endif
    ...
    

    Thanks


  • Lifetime Qt Champion

    Hi,

    IIRC, you need to use QT_DISABLE_DEPRECATED_BEFORE with a value 0x040900

    Hope it helps



  • Hi,

    Thanks for the response. Could you give a little more detail? How would the QT_DISABLE_DEPRECATED_BEFORE flag be set?

    Thanks


  • Lifetime Qt Champion

    Add

    DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x040900

    to your pro file and your should be good to go


Log in to reply