From b8644eab5205a9ff20ad27836be2439e7f6a19e9 Mon Sep 17 00:00:00 2001 From: Jerome Pasion Date: Fri, 10 Sep 2010 17:29:04 +0200 Subject: Clarified the coding standard regarding connecting signals to slots. Cleaned up the contradiction identified in QTBUG-10114. Reviewed-by: David Boddie Bug: QTBUG-8961, QTBUG-10114 --- doc/src/objectmodel/signalsandslots.qdoc | 6 +++++- doc/src/snippets/signalmapper/filereader.cpp | 12 ++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/doc/src/objectmodel/signalsandslots.qdoc b/doc/src/objectmodel/signalsandslots.qdoc index 09c427b..c12ca78 100644 --- a/doc/src/objectmodel/signalsandslots.qdoc +++ b/doc/src/objectmodel/signalsandslots.qdoc @@ -336,7 +336,7 @@ If on the other hand you want to call two different error functions when the number overflows, simply connect the signal to - two different slots. Qt will call both (in arbitrary order). + two different slots. Qt will call both (in the order they were connected). \snippet doc/src/snippets/signalsandslots/lcdnumber.h 10 \snippet doc/src/snippets/signalsandslots/lcdnumber.h 11 @@ -427,6 +427,10 @@ \snippet doc/src/snippets/signalmapper/filereader.cpp 1 + \note The following code will compile and run, but due to signature normalization, the code will be slower. + + \snippet doc/src/snippets/signalmapper/filereader.cpp 2 + \sa {Meta-Object System}, {Qt's Property System} \target 3rd Party Signals and Slots diff --git a/doc/src/snippets/signalmapper/filereader.cpp b/doc/src/snippets/signalmapper/filereader.cpp index 76ed4c1..08f4d06 100644 --- a/doc/src/snippets/signalmapper/filereader.cpp +++ b/doc/src/snippets/signalmapper/filereader.cpp @@ -66,10 +66,18 @@ FileReader::FileReader(QWidget *parent) //! [0] //! [1] - connect(signalMapper, SIGNAL(mapped(const QString &)), - this, SLOT(readFile(const QString &))); + connect(signalMapper, SIGNAL(mapped(QString)), + this, SLOT(readFile(QString))); //! [1] +/* +//! [2] + //slower due to signature normalization at runtime + + connect(signalMapper, SIGNAL(mapped(const QString &)), + this, SLOT(readFile(const QString &))); +//! [2] +*/ QHBoxLayout *buttonLayout = new QHBoxLayout; buttonLayout->addWidget(taxFileButton); buttonLayout->addWidget(accountFileButton); -- cgit v0.12