From 60c70e4efffb725f8239a901717a8dd3c4eef259 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Tue, 22 Mar 2022 16:06:37 +0100 Subject: [PATCH] Doc: Document QT_NO_[SIGNALS_SLOTS_]KEYWORDS defines Pick-to: 6.2 6.3 Fixes: QTBUG-70564 Change-Id: I8ed1a30567dabdcb95cdfce009f1d9e0645d3226 Reviewed-by: Fabian Kosmale --- .../doc/snippets/code/doc_src_containers.cpp | 5 ++++ .../doc/src/objectmodel/signalsandslots.qdoc | 25 ++++++++++++++++--- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/src/corelib/doc/snippets/code/doc_src_containers.cpp b/src/corelib/doc/snippets/code/doc_src_containers.cpp index 47cfb0dc51..a191c9af5c 100644 --- a/src/corelib/doc/snippets/code/doc_src_containers.cpp +++ b/src/corelib/doc/snippets/code/doc_src_containers.cpp @@ -272,6 +272,11 @@ CONFIG += no_keywords //! [22] +//! [cmake_no_keywords] +target_compile_definitions(my_app PRIVATE QT_NO_KEYWORDS) +//! [cmake_no_keywords] + + //! [23] QString onlyLetters(const QString &in) { diff --git a/src/corelib/doc/src/objectmodel/signalsandslots.qdoc b/src/corelib/doc/src/objectmodel/signalsandslots.qdoc index 85fe4df2ce..c288129e3e 100644 --- a/src/corelib/doc/src/objectmodel/signalsandslots.qdoc +++ b/src/corelib/doc/src/objectmodel/signalsandslots.qdoc @@ -412,8 +412,12 @@ \section2 Using Qt with 3rd Party Signals and Slots It is possible to use Qt with a 3rd party signal/slot mechanism. - You can even use both mechanisms in the same project. Just add the - following line to your qmake project (.pro) file. + You can even use both mechanisms in the same project. To do that, + write the following into your CMake project file: + + \snippet code/doc_src_containers.cpp cmake_no_keywords + + In a qmake project (.pro) file, you need to write: \snippet code/doc_src_containers.cpp 22 @@ -423,4 +427,19 @@ with the \c{no_keywords} flag, simply replace all uses of the Qt moc keywords in your sources with the corresponding Qt macros Q_SIGNALS (or Q_SIGNAL), Q_SLOTS (or Q_SLOT), and Q_EMIT. -*/ + + \section2 Signals and slots in Qt-based libraries + + The public API of Qt-based libraries should use the keywords + \c{Q_SIGNALS} and \c{Q_SLOTS} instead of \c{signals} and + \c{slots}. Otherwise it is hard to use such a library in a project + that defines \c{QT_NO_KEYWORDS}. + + To enforce this restriction, the library creator may set the + preprocessor define \c{QT_NO_SIGNALS_SLOTS_KEYWORDS} when building + the library. + + This define excludes signals and slots without affecting whether + other Qt-specific keywords can be used in the library + implementation. + */