diff options
author | Olivier Goffart <ogoffart@woboq.com> | 2012-04-24 15:01:47 +0200 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-05-02 10:59:41 +0200 |
commit | bcd477e0bc48bb028193d7707d1ecfbd61b5bdc1 (patch) | |
tree | 5b34c02f76c4e9c8b3aeb7eec6fc69ac3b864e24 /src/corelib/doc/snippets/code/src_corelib_kernel_qobject.cpp | |
parent | ade888860334d207f5f070b0bc9c4c98deaf3862 (diff) |
Introduce QObject::isSignalConnected(QMetaMethod)
This is much more performant than calling QObject::receivers(const char*)
Can be used instead of connectNotify in some cases.
Change-Id: I19e0933f678f171f515d9a0f69f0ad4fb7d894b4
Reviewed-by: Kent Hansen <kent.hansen@nokia.com>
Diffstat (limited to 'src/corelib/doc/snippets/code/src_corelib_kernel_qobject.cpp')
-rw-r--r-- | src/corelib/doc/snippets/code/src_corelib_kernel_qobject.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/corelib/doc/snippets/code/src_corelib_kernel_qobject.cpp b/src/corelib/doc/snippets/code/src_corelib_kernel_qobject.cpp index 2367bfd724..95c54169ce 100644 --- a/src/corelib/doc/snippets/code/src_corelib_kernel_qobject.cpp +++ b/src/corelib/doc/snippets/code/src_corelib_kernel_qobject.cpp @@ -479,6 +479,14 @@ QObject::disconnect(lineEdit, &QLineEdit::textChanged, label, &QLabel::setText); //! [48] +//! [49] +if (isSignalConnected(QMethaMethod::fromSignal(&MyObject::valueChanged))) { + QByteArray data; + data = get_the_value(); // expensive operation + emit valueChanged(data); +} +//! [49] + //! [meta data] //: This is a comment for the translator. //= qtn_foo_bar |