diff options
author | Christian Ehrlicher <ch.ehrlicher@gmx.de> | 2018-12-07 14:17:02 +0100 |
---|---|---|
committer | Christian Ehrlicher <ch.ehrlicher@gmx.de> | 2019-01-06 17:07:59 +0000 |
commit | cf27d9e8a5e14ebe083f4b0fa2204d0646e7ed5e (patch) | |
tree | 56ab889591e8cdb919f9b5b3ac6a46af6126a2da /examples/widgets/painting/painterpaths | |
parent | 283008e123e5eacb83869682528b2024186634f8 (diff) |
Cleanup Widgets examples - new signal/slot syntax
Cleanup the Widget examples - use the new signal/slot syntax where
possible - painting and richtext subdirectory
Change-Id: If0e365ab1cabf9184076595494cfca151406fddf
Reviewed-by: Luca Beldi <v.ronin@yahoo.it>
Reviewed-by: Topi Reiniƶ <topi.reinio@qt.io>
Diffstat (limited to 'examples/widgets/painting/painterpaths')
-rw-r--r-- | examples/widgets/painting/painterpaths/window.cpp | 42 |
1 files changed, 25 insertions, 17 deletions
diff --git a/examples/widgets/painting/painterpaths/window.cpp b/examples/widgets/painting/painterpaths/window.cpp index a987937b39..95e312623e 100644 --- a/examples/widgets/painting/painterpaths/window.cpp +++ b/examples/widgets/painting/painterpaths/window.cpp @@ -194,22 +194,30 @@ Window::Window() //! [12] //! [16] - connect(fillRuleComboBox, SIGNAL(activated(int)), this, SLOT(fillRuleChanged())); - connect(fillColor1ComboBox, SIGNAL(activated(int)), this, SLOT(fillGradientChanged())); - connect(fillColor2ComboBox, SIGNAL(activated(int)), this, SLOT(fillGradientChanged())); - connect(penColorComboBox, SIGNAL(activated(int)), this, SLOT(penColorChanged())); - - for(QList<RenderArea*>::iterator it = renderAreas.begin(); it != renderAreas.end(); it++) { - connect(penWidthSpinBox, SIGNAL(valueChanged(int)), *it, SLOT(setPenWidth(int))); - connect(rotationAngleSpinBox, SIGNAL(valueChanged(int)), *it, SLOT(setRotationAngle(int))); + connect(fillRuleComboBox, QOverload<int>::of(&QComboBox::activated), + this, &Window::fillRuleChanged); + connect(fillColor1ComboBox, QOverload<int>::of(&QComboBox::activated), + this, &Window::fillGradientChanged); + connect(fillColor2ComboBox, QOverload<int>::of(&QComboBox::activated), + this, &Window::fillGradientChanged); + connect(penColorComboBox, QOverload<int>::of(&QComboBox::activated), + this, &Window::penColorChanged); + + for (RenderArea *area : qAsConst(renderAreas)) { + connect(penWidthSpinBox, QOverload<int>::of(&QSpinBox::valueChanged), + area, &RenderArea::setPenWidth); + connect(rotationAngleSpinBox, QOverload<int>::of(&QSpinBox::valueChanged), + area, &RenderArea::setRotationAngle); } //! [16] //! [17] QGridLayout *topLayout = new QGridLayout; - int i=0; - for(QList<RenderArea*>::iterator it = renderAreas.begin(); it != renderAreas.end(); it++, i++) - topLayout->addWidget(*it, i / 3, i % 3); + int i = 0; + for (RenderArea *area : qAsConst(renderAreas)) { + topLayout->addWidget(area, i / 3, i % 3); + ++i; + } QGridLayout *mainLayout = new QGridLayout; mainLayout->addLayout(topLayout, 0, 0, 1, 4); @@ -243,8 +251,8 @@ void Window::fillRuleChanged() { Qt::FillRule rule = (Qt::FillRule)currentItemData(fillRuleComboBox).toInt(); - for (QList<RenderArea*>::iterator it = renderAreas.begin(); it != renderAreas.end(); ++it) - (*it)->setFillRule(rule); + for (RenderArea *area : qAsConst(renderAreas)) + area->setFillRule(rule); } //! [19] @@ -254,8 +262,8 @@ void Window::fillGradientChanged() QColor color1 = qvariant_cast<QColor>(currentItemData(fillColor1ComboBox)); QColor color2 = qvariant_cast<QColor>(currentItemData(fillColor2ComboBox)); - for (QList<RenderArea*>::iterator it = renderAreas.begin(); it != renderAreas.end(); ++it) - (*it)->setFillGradient(color1, color2); + for (RenderArea *area : qAsConst(renderAreas)) + area->setFillGradient(color1, color2); } //! [20] @@ -264,8 +272,8 @@ void Window::penColorChanged() { QColor color = qvariant_cast<QColor>(currentItemData(penColorComboBox)); - for (QList<RenderArea*>::iterator it = renderAreas.begin(); it != renderAreas.end(); ++it) - (*it)->setPenColor(color); + for (RenderArea *area : qAsConst(renderAreas)) + area->setPenColor(color); } //! [21] |