From fb7bfbf18d91d0bd0f1c88ee6043e3dfa7ae9b9e Mon Sep 17 00:00:00 2001 From: Alexander Volkov Date: Tue, 20 Dec 2016 21:37:37 +0300 Subject: examples: Use QOverload to select overloaded signals and slots We can use QOverload since Qt 5.7 (it depends on Q_COMPILER_VARIADIC_TEMPLATES which is required since Qt 5.7). Use it in the examples to show the best practice. qOverload currently can't be used because it requires c++14. Change-Id: I94a3c0db9d551fe169fa3d19c07ec0b329d5946c Reviewed-by: Friedemann Kleint Reviewed-by: Olivier Goffart (Woboq GmbH) --- examples/widgets/richtext/textedit/textedit.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'examples/widgets/richtext') diff --git a/examples/widgets/richtext/textedit/textedit.cpp b/examples/widgets/richtext/textedit/textedit.cpp index dec0b0bd35..140ae478ff 100644 --- a/examples/widgets/richtext/textedit/textedit.cpp +++ b/examples/widgets/richtext/textedit/textedit.cpp @@ -342,13 +342,11 @@ void TextEdit::setupTextActions() comboStyle->addItem("Ordered List (Roman lower)"); comboStyle->addItem("Ordered List (Roman upper)"); - typedef void (QComboBox::*QComboIntSignal)(int); - connect(comboStyle, static_cast(&QComboBox::activated), this, &TextEdit::textStyle); + connect(comboStyle, QOverload::of(&QComboBox::activated), this, &TextEdit::textStyle); - typedef void (QComboBox::*QComboStringSignal)(const QString &); comboFont = new QFontComboBox(tb); tb->addWidget(comboFont); - connect(comboFont, static_cast(&QComboBox::activated), this, &TextEdit::textFamily); + connect(comboFont, QOverload::of(&QComboBox::activated), this, &TextEdit::textFamily); comboSize = new QComboBox(tb); comboSize->setObjectName("comboSize"); @@ -360,7 +358,7 @@ void TextEdit::setupTextActions() comboSize->addItem(QString::number(size)); comboSize->setCurrentIndex(standardSizes.indexOf(QApplication::font().pointSize())); - connect(comboSize, static_cast(&QComboBox::activated), this, &TextEdit::textSize); + connect(comboSize, QOverload::of(&QComboBox::activated), this, &TextEdit::textSize); } bool TextEdit::load(const QString &f) -- cgit v1.2.3