Obsolete Members for <QtCompilerDetection>

<QtCompilerDetection> 的以下成员已被弃用。提供这些成员是为了保持旧源代码的正常运行。我们强烈建议不要在新代码中使用它们。

(deprecated) Q_CC_INTEL
(deprecated in 6.4) Q_DECL_CONSTEXPR
(deprecated) Q_DECL_FINAL
(deprecated in 6.4) Q_DECL_NOEXCEPT
(deprecated in 6.4) Q_DECL_NOEXCEPT_EXPR(x)
(deprecated in 6.4) Q_DECL_NOTHROW
(deprecated) Q_DECL_OVERRIDE
(deprecated in 6.4) Q_DECL_RELAXED_CONSTEXPR

宏文档

[deprecated] Q_CC_INTEL

该宏已被弃用。我们强烈建议不要在新代码中使用它。

如果应用程序是使用旧的 Intel C++ 编译器(用于 Linux、macOS 或 Windows)编译的,则需要定义此宏。新的 oneAPI C++ 编译器只是 Clang 的一个构建版本,因此没有定义此宏。

另请参见 Q_CC_CLANG

[deprecated in 6.4] Q_DECL_CONSTEXPR

自 6.4 版起,该宏已被弃用。我们强烈建议不要在新代码中使用它。

请使用constexpr 关键字。

该宏可用于声明应在编译时构造的变量,或可在编译时计算的内联函数。

另请参阅 Q_DECL_RELAXED_CONSTEXPRQ_DECL_CONSTEXPR_DTOR

[deprecated] Q_DECL_FINAL

该宏已被弃用。我们强烈建议不要在新代码中使用它。

该宏可用于将一个重载虚函数或一个类声明为 "final",具有 Java 语义。这样,后续派生类就不能再覆盖此虚函数,也不能再从该类继承。

它会扩展为 "final"。

宏放在函数的末尾,通常在const 之后(如果有的话):

    // more-derived classes no longer permitted to override this:
    virtual void MyWidget::paintEvent(QPaintEvent*) final;

对于类来说,如果有的话,它位于类定义中: 的前面:

    class QRect final { // cannot be derived from
        // ...
    };

另请参见 Q_DECL_OVERRIDE

[deprecated in 6.4] Q_DECL_NOEXCEPT

自 6.4 版起,该宏已被弃用。我们强烈建议不要在新代码中使用它。

请使用noexcept 关键字。

该宏将函数标记为永不抛出。如果函数仍然抛出,其行为将被定义为:调用 std::terminate()。

另请参见 Q_DECL_NOTHROWQ_DECL_NOEXCEPT_EXPR()。

[deprecated in 6.4] Q_DECL_NOEXCEPT_EXPR(x)

自 6.4 版起,该宏已被弃用。我们强烈建议不要在新代码中使用它。

请使用noexcept 关键字。

如果xtrue ,则此宏将函数标记为非抛出函数。如果函数仍然抛出,则会定义行为:调用 std::termininate()。

另请参见 Q_DECL_NOTHROWQ_DECL_NOEXCEPT

[deprecated in 6.4] Q_DECL_NOTHROW

自 6.4 版起,该宏已被弃用。我们强烈建议不要在新代码中使用它。

请使用noexcept 关键字。

该宏将函数标记为在任何情况下都不会抛出。如果函数确实抛出,则其行为是未定义的。

另请参见 Q_DECL_NOEXCEPTQ_DECL_NOEXCEPT_EXPR()。

[deprecated] Q_DECL_OVERRIDE

该宏已被弃用。我们强烈建议不要在新代码中使用它。

该宏可用于声明覆盖虚函数。如果覆盖的虚函数实际上没有覆盖任何东西,使用此标记将允许编译器生成错误。

它会展开为 "覆盖"。

宏放在函数的末尾,通常在const 之后(如果有的话):

    // generate error if this doesn't actually override anything:
    virtual void MyWidget::paintEvent(QPaintEvent*) override;

另请参见 Q_DECL_FINAL

[deprecated in 6.4] Q_DECL_RELAXED_CONSTEXPR

自 6.4 版起,该宏已被弃用。我们强烈建议不要在新代码中使用它。

请使用constexpr 关键字。

此宏可用于声明内联函数,该函数可在编译时根据 C++14 的宽松规则进行计算。

另请参见 Q_DECL_CONSTEXPRQ_DECL_CONSTEXPR_DTOR

© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.