summaryrefslogtreecommitdiffstats
path: root/examples/widgets/painting
diff options
context:
space:
mode:
Diffstat (limited to 'examples/widgets/painting')
-rw-r--r--examples/widgets/painting/affine/main.cpp8
-rw-r--r--examples/widgets/painting/basicdrawing/window.cpp32
-rw-r--r--examples/widgets/painting/composition/composition.cpp66
-rw-r--r--examples/widgets/painting/composition/main.cpp4
-rw-r--r--examples/widgets/painting/concentriccircles/window.cpp4
-rw-r--r--examples/widgets/painting/deform/main.cpp8
-rw-r--r--examples/widgets/painting/deform/pathdeform.cpp55
-rw-r--r--examples/widgets/painting/deform/pathdeform.h4
-rw-r--r--examples/widgets/painting/fontsampler/mainwindow.cpp50
-rw-r--r--examples/widgets/painting/gradients/gradients.cpp4
-rw-r--r--examples/widgets/painting/gradients/main.cpp4
-rw-r--r--examples/widgets/painting/imagecomposition/imagecomposer.cpp9
-rw-r--r--examples/widgets/painting/painterpaths/window.cpp46
-rw-r--r--examples/widgets/painting/pathstroke/main.cpp4
-rw-r--r--examples/widgets/painting/pathstroke/pathstroke.cpp76
-rw-r--r--examples/widgets/painting/shared/arthurstyle.cpp10
-rw-r--r--examples/widgets/painting/shared/arthurwidgets.cpp46
-rw-r--r--examples/widgets/painting/shared/hoverpoints.cpp6
-rw-r--r--examples/widgets/painting/transformations/window.cpp7
19 files changed, 233 insertions, 210 deletions
diff --git a/examples/widgets/painting/affine/main.cpp b/examples/widgets/painting/affine/main.cpp
index a820c784f0..6ce8efe482 100644
--- a/examples/widgets/painting/affine/main.cpp
+++ b/examples/widgets/painting/affine/main.cpp
@@ -58,12 +58,12 @@ int main(int argc, char **argv)
QApplication app(argc, argv);
- XFormWidget xformWidget(0);
- QStyle *arthurStyle = new ArthurStyle();
+ XFormWidget xformWidget(nullptr);
+ QStyle *arthurStyle = new ArthurStyle;
xformWidget.setStyle(arthurStyle);
- QList<QWidget *> widgets = xformWidget.findChildren<QWidget *>();
- foreach (QWidget *w, widgets) {
+ const QList<QWidget *> widgets = xformWidget.findChildren<QWidget *>();
+ for (QWidget *w : widgets) {
w->setStyle(arthurStyle);
w->setAttribute(Qt::WA_AcceptTouchEvents);
}
diff --git a/examples/widgets/painting/basicdrawing/window.cpp b/examples/widgets/painting/basicdrawing/window.cpp
index c80237e914..65f6971d13 100644
--- a/examples/widgets/painting/basicdrawing/window.cpp
+++ b/examples/widgets/painting/basicdrawing/window.cpp
@@ -157,22 +157,22 @@ Window::Window()
//! [7]
//! [8]
- connect(shapeComboBox, SIGNAL(activated(int)),
- this, SLOT(shapeChanged()));
- connect(penWidthSpinBox, SIGNAL(valueChanged(int)),
- this, SLOT(penChanged()));
- connect(penStyleComboBox, SIGNAL(activated(int)),
- this, SLOT(penChanged()));
- connect(penCapComboBox, SIGNAL(activated(int)),
- this, SLOT(penChanged()));
- connect(penJoinComboBox, SIGNAL(activated(int)),
- this, SLOT(penChanged()));
- connect(brushStyleComboBox, SIGNAL(activated(int)),
- this, SLOT(brushChanged()));
- connect(antialiasingCheckBox, SIGNAL(toggled(bool)),
- renderArea, SLOT(setAntialiased(bool)));
- connect(transformationsCheckBox, SIGNAL(toggled(bool)),
- renderArea, SLOT(setTransformed(bool)));
+ connect(shapeComboBox, QOverload<int>::of(&QComboBox::activated),
+ this, &Window::shapeChanged);
+ connect(penWidthSpinBox, QOverload<int>::of(&QSpinBox::valueChanged),
+ this, &Window::penChanged);
+ connect(penStyleComboBox, QOverload<int>::of(&QComboBox::activated),
+ this, &Window::penChanged);
+ connect(penCapComboBox, QOverload<int>::of(&QComboBox::activated),
+ this, &Window::penChanged);
+ connect(penJoinComboBox, QOverload<int>::of(&QComboBox::activated),
+ this, &Window::penChanged);
+ connect(brushStyleComboBox, QOverload<int>::of(&QComboBox::activated),
+ this, &Window::brushChanged);
+ connect(antialiasingCheckBox, &QAbstractButton::toggled,
+ renderArea, &RenderArea::setAntialiased);
+ connect(transformationsCheckBox, &QAbstractButton::toggled,
+ renderArea, &RenderArea::setTransformed);
//! [8]
//! [9]
diff --git a/examples/widgets/painting/composition/composition.cpp b/examples/widgets/painting/composition/composition.cpp
index e0abc5875c..9bd71735a0 100644
--- a/examples/widgets/painting/composition/composition.cpp
+++ b/examples/widgets/painting/composition/composition.cpp
@@ -76,68 +76,68 @@ CompositionWidget::CompositionWidget(QWidget *parent)
modesGroup->setTitle(tr("Mode"));
rbClear = new QRadioButton(tr("Clear"), modesGroup);
- connect(rbClear, SIGNAL(clicked()), view, SLOT(setClearMode()));
+ connect(rbClear, &QAbstractButton::clicked, view, &CompositionRenderer::setClearMode);
rbSource = new QRadioButton(tr("Source"), modesGroup);
- connect(rbSource, SIGNAL(clicked()), view, SLOT(setSourceMode()));
+ connect(rbSource, &QAbstractButton::clicked, view, &CompositionRenderer::setSourceMode);
rbDest = new QRadioButton(tr("Destination"), modesGroup);
- connect(rbDest, SIGNAL(clicked()), view, SLOT(setDestMode()));
+ connect(rbDest, &QAbstractButton::clicked, view, &CompositionRenderer::setDestMode);
rbSourceOver = new QRadioButton(tr("Source Over"), modesGroup);
- connect(rbSourceOver, SIGNAL(clicked()), view, SLOT(setSourceOverMode()));
+ connect(rbSourceOver, &QAbstractButton::clicked, view, &CompositionRenderer::setSourceOverMode);
rbDestOver = new QRadioButton(tr("Destination Over"), modesGroup);
- connect(rbDestOver, SIGNAL(clicked()), view, SLOT(setDestOverMode()));
+ connect(rbDestOver, &QAbstractButton::clicked, view, &CompositionRenderer::setDestOverMode);
rbSourceIn = new QRadioButton(tr("Source In"), modesGroup);
- connect(rbSourceIn, SIGNAL(clicked()), view, SLOT(setSourceInMode()));
+ connect(rbSourceIn, &QAbstractButton::clicked, view, &CompositionRenderer::setSourceInMode);
rbDestIn = new QRadioButton(tr("Dest In"), modesGroup);
- connect(rbDestIn, SIGNAL(clicked()), view, SLOT(setDestInMode()));
+ connect(rbDestIn, &QAbstractButton::clicked, view, &CompositionRenderer::setDestInMode);
rbSourceOut = new QRadioButton(tr("Source Out"), modesGroup);
- connect(rbSourceOut, SIGNAL(clicked()), view, SLOT(setSourceOutMode()));
+ connect(rbSourceOut, &QAbstractButton::clicked, view, &CompositionRenderer::setSourceOutMode);
rbDestOut = new QRadioButton(tr("Dest Out"), modesGroup);
- connect(rbDestOut, SIGNAL(clicked()), view, SLOT(setDestOutMode()));
+ connect(rbDestOut, &QAbstractButton::clicked, view, &CompositionRenderer::setDestOutMode);
rbSourceAtop = new QRadioButton(tr("Source Atop"), modesGroup);
- connect(rbSourceAtop, SIGNAL(clicked()), view, SLOT(setSourceAtopMode()));
+ connect(rbSourceAtop, &QAbstractButton::clicked, view, &CompositionRenderer::setSourceAtopMode);
rbDestAtop = new QRadioButton(tr("Dest Atop"), modesGroup);
- connect(rbDestAtop, SIGNAL(clicked()), view, SLOT(setDestAtopMode()));
+ connect(rbDestAtop, &QAbstractButton::clicked, view, &CompositionRenderer::setDestAtopMode);
rbXor = new QRadioButton(tr("Xor"), modesGroup);
- connect(rbXor, SIGNAL(clicked()), view, SLOT(setXorMode()));
+ connect(rbXor, &QAbstractButton::clicked, view, &CompositionRenderer::setXorMode);
rbPlus = new QRadioButton(tr("Plus"), modesGroup);
- connect(rbPlus, SIGNAL(clicked()), view, SLOT(setPlusMode()));
+ connect(rbPlus, &QAbstractButton::clicked, view, &CompositionRenderer::setPlusMode);
rbMultiply = new QRadioButton(tr("Multiply"), modesGroup);
- connect(rbMultiply, SIGNAL(clicked()), view, SLOT(setMultiplyMode()));
+ connect(rbMultiply, &QAbstractButton::clicked, view, &CompositionRenderer::setMultiplyMode);
rbScreen = new QRadioButton(tr("Screen"), modesGroup);
- connect(rbScreen, SIGNAL(clicked()), view, SLOT(setScreenMode()));
+ connect(rbScreen, &QAbstractButton::clicked, view, &CompositionRenderer::setScreenMode);
rbOverlay = new QRadioButton(tr("Overlay"), modesGroup);
- connect(rbOverlay, SIGNAL(clicked()), view, SLOT(setOverlayMode()));
+ connect(rbOverlay, &QAbstractButton::clicked, view, &CompositionRenderer::setOverlayMode);
rbDarken = new QRadioButton(tr("Darken"), modesGroup);
- connect(rbDarken, SIGNAL(clicked()), view, SLOT(setDarkenMode()));
+ connect(rbDarken, &QAbstractButton::clicked, view, &CompositionRenderer::setDarkenMode);
rbLighten = new QRadioButton(tr("Lighten"), modesGroup);
- connect(rbLighten, SIGNAL(clicked()), view, SLOT(setLightenMode()));
+ connect(rbLighten, &QAbstractButton::clicked, view, &CompositionRenderer::setLightenMode);
rbColorDodge = new QRadioButton(tr("Color Dodge"), modesGroup);
- connect(rbColorDodge, SIGNAL(clicked()), view, SLOT(setColorDodgeMode()));
+ connect(rbColorDodge, &QAbstractButton::clicked, view, &CompositionRenderer::setColorDodgeMode);
rbColorBurn = new QRadioButton(tr("Color Burn"), modesGroup);
- connect(rbColorBurn, SIGNAL(clicked()), view, SLOT(setColorBurnMode()));
+ connect(rbColorBurn, &QAbstractButton::clicked, view, &CompositionRenderer::setColorBurnMode);
rbHardLight = new QRadioButton(tr("Hard Light"), modesGroup);
- connect(rbHardLight, SIGNAL(clicked()), view, SLOT(setHardLightMode()));
+ connect(rbHardLight, &QAbstractButton::clicked, view, &CompositionRenderer::setHardLightMode);
rbSoftLight = new QRadioButton(tr("Soft Light"), modesGroup);
- connect(rbSoftLight, SIGNAL(clicked()), view, SLOT(setSoftLightMode()));
+ connect(rbSoftLight, &QAbstractButton::clicked, view, &CompositionRenderer::setSoftLightMode);
rbDifference = new QRadioButton(tr("Difference"), modesGroup);
- connect(rbDifference, SIGNAL(clicked()), view, SLOT(setDifferenceMode()));
+ connect(rbDifference, &QAbstractButton::clicked, view, &CompositionRenderer::setDifferenceMode);
rbExclusion = new QRadioButton(tr("Exclusion"), modesGroup);
- connect(rbExclusion, SIGNAL(clicked()), view, SLOT(setExclusionMode()));
+ connect(rbExclusion, &QAbstractButton::clicked, view, &CompositionRenderer::setExclusionMode);
QGroupBox *circleColorGroup = new QGroupBox(mainGroup);
circleColorGroup->setTitle(tr("Circle color"));
QSlider *circleColorSlider = new QSlider(Qt::Horizontal, circleColorGroup);
circleColorSlider->setRange(0, 359);
circleColorSlider->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
- connect(circleColorSlider, SIGNAL(valueChanged(int)), view, SLOT(setCircleColor(int)));
+ connect(circleColorSlider, &QAbstractSlider::valueChanged, view, &CompositionRenderer::setCircleColor);
QGroupBox *circleAlphaGroup = new QGroupBox(mainGroup);
circleAlphaGroup->setTitle(tr("Circle alpha"));
QSlider *circleAlphaSlider = new QSlider(Qt::Horizontal, circleAlphaGroup);
circleAlphaSlider->setRange(0, 255);
circleAlphaSlider->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
- connect(circleAlphaSlider, SIGNAL(valueChanged(int)), view, SLOT(setCircleAlpha(int)));
+ connect(circleAlphaSlider, &QAbstractSlider::valueChanged, view, &CompositionRenderer::setCircleAlpha);
QPushButton *showSourceButton = new QPushButton(mainGroup);
showSourceButton->setText(tr("Show Source"));
@@ -209,13 +209,13 @@ CompositionWidget::CompositionWidget(QWidget *parent)
view->loadDescription(":res/composition/composition.html");
view->loadSourceFile(":res/composition/composition.cpp");
- connect(whatsThisButton, SIGNAL(clicked(bool)), view, SLOT(setDescriptionEnabled(bool)));
- connect(view, SIGNAL(descriptionEnabledChanged(bool)), whatsThisButton, SLOT(setChecked(bool)));
- connect(showSourceButton, SIGNAL(clicked()), view, SLOT(showSource()));
+ connect(whatsThisButton, &QAbstractButton::clicked, view, &ArthurFrame::setDescriptionEnabled);
+ connect(view, &ArthurFrame::descriptionEnabledChanged, whatsThisButton, &QAbstractButton::setChecked);
+ connect(showSourceButton, &QAbstractButton::clicked, view, &ArthurFrame::showSource);
#if QT_CONFIG(opengl)
- connect(enableOpenGLButton, SIGNAL(clicked(bool)), view, SLOT(enableOpenGL(bool)));
+ connect(enableOpenGLButton, &QAbstractButton::clicked, view, &ArthurFrame::enableOpenGL);
#endif
- connect(animateButton, SIGNAL(toggled(bool)), view, SLOT(setAnimationEnabled(bool)));
+ connect(animateButton, &QAbstractButton::toggled, view, &CompositionRenderer::setAnimationEnabled);
circleColorSlider->setValue(270);
circleAlphaSlider->setValue(200);
@@ -341,9 +341,9 @@ void CompositionRenderer::drawSource(QPainter &p)
QRectF circle_rect = rectangle_around(m_circle_pos);
QColor color = QColor::fromHsvF(m_circle_hue / 360.0, 1, 1, m_circle_alpha / 255.0);
QLinearGradient circle_gradient(circle_rect.topLeft(), circle_rect.bottomRight());
- circle_gradient.setColorAt(0, color.light());
+ circle_gradient.setColorAt(0, color.lighter());
circle_gradient.setColorAt(0.5, color);
- circle_gradient.setColorAt(1, color.dark());
+ circle_gradient.setColorAt(1, color.darker());
p.setBrush(circle_gradient);
p.drawEllipse(circle_rect);
diff --git a/examples/widgets/painting/composition/main.cpp b/examples/widgets/painting/composition/main.cpp
index 1f4ead7165..2eaeaba2c5 100644
--- a/examples/widgets/painting/composition/main.cpp
+++ b/examples/widgets/painting/composition/main.cpp
@@ -60,8 +60,8 @@ int main(int argc, char *argv[])
QStyle *arthurStyle = new ArthurStyle();
compWidget.setStyle(arthurStyle);
- QList<QWidget *> widgets = compWidget.findChildren<QWidget *>();
- foreach (QWidget *w, widgets)
+ const QList<QWidget *> widgets = compWidget.findChildren<QWidget *>();
+ for (QWidget *w : widgets)
w->setStyle(arthurStyle);
compWidget.show();
diff --git a/examples/widgets/painting/concentriccircles/window.cpp b/examples/widgets/painting/concentriccircles/window.cpp
index 0f65dc2285..45258e0bc4 100644
--- a/examples/widgets/painting/concentriccircles/window.cpp
+++ b/examples/widgets/painting/concentriccircles/window.cpp
@@ -77,8 +77,8 @@ Window::Window()
circleWidgets[i][j]->setAntialiased(j != 0);
circleWidgets[i][j]->setFloatBased(i != 0);
- connect(timer, SIGNAL(timeout()),
- circleWidgets[i][j], SLOT(nextAnimationFrame()));
+ connect(timer, &QTimer::timeout,
+ circleWidgets[i][j], &CircleWidget::nextAnimationFrame);
layout->addWidget(circleWidgets[i][j], i + 1, j + 1);
}
diff --git a/examples/widgets/painting/deform/main.cpp b/examples/widgets/painting/deform/main.cpp
index 85e83207c0..28e3d6823d 100644
--- a/examples/widgets/painting/deform/main.cpp
+++ b/examples/widgets/painting/deform/main.cpp
@@ -60,12 +60,12 @@ int main(int argc, char **argv)
bool smallScreen = QApplication::arguments().contains("-small-screen");
- PathDeformWidget deformWidget(0, smallScreen);
+ PathDeformWidget deformWidget(nullptr, smallScreen);
- QStyle *arthurStyle = new ArthurStyle();
+ QStyle *arthurStyle = new ArthurStyle;
deformWidget.setStyle(arthurStyle);
- QList<QWidget *> widgets = deformWidget.findChildren<QWidget *>();
- foreach (QWidget *w, widgets)
+ const QList<QWidget *> widgets = deformWidget.findChildren<QWidget *>();
+ for (QWidget *w : widgets)
w->setStyle(arthurStyle);
if (smallScreen)
diff --git a/examples/widgets/painting/deform/pathdeform.cpp b/examples/widgets/painting/deform/pathdeform.cpp
index 7c3fe45277..64e81f8cab 100644
--- a/examples/widgets/painting/deform/pathdeform.cpp
+++ b/examples/widgets/painting/deform/pathdeform.cpp
@@ -150,21 +150,21 @@ void PathDeformControls::layoutForDesktop()
QVBoxLayout * mainLayout = new QVBoxLayout(this);
mainLayout->addWidget(mainGroup);
- mainLayout->setMargin(0);
+ mainLayout->setContentsMargins(QMargins());
- connect(radiusSlider, SIGNAL(valueChanged(int)), m_renderer, SLOT(setRadius(int)));
- connect(deformSlider, SIGNAL(valueChanged(int)), m_renderer, SLOT(setIntensity(int)));
- connect(fontSizeSlider, SIGNAL(valueChanged(int)), m_renderer, SLOT(setFontSize(int)));
- connect(animateButton, SIGNAL(clicked(bool)), m_renderer, SLOT(setAnimated(bool)));
+ connect(radiusSlider, &QAbstractSlider::valueChanged, m_renderer, &PathDeformRenderer::setRadius);
+ connect(deformSlider, &QAbstractSlider::valueChanged, m_renderer, &PathDeformRenderer::setIntensity);
+ connect(fontSizeSlider, &QAbstractSlider::valueChanged, m_renderer, &PathDeformRenderer::setFontSize);
+ connect(animateButton, &QAbstractButton::clicked, m_renderer, &PathDeformRenderer::setAnimated);
#if QT_CONFIG(opengl)
- connect(enableOpenGLButton, SIGNAL(clicked(bool)), m_renderer, SLOT(enableOpenGL(bool)));
+ connect(enableOpenGLButton, &QAbstractButton::clicked, m_renderer, &ArthurFrame::enableOpenGL);
#endif
- connect(textInput, SIGNAL(textChanged(QString)), m_renderer, SLOT(setText(QString)));
- connect(m_renderer, SIGNAL(descriptionEnabledChanged(bool)),
- whatsThisButton, SLOT(setChecked(bool)));
- connect(whatsThisButton, SIGNAL(clicked(bool)), m_renderer, SLOT(setDescriptionEnabled(bool)));
- connect(showSourceButton, SIGNAL(clicked()), m_renderer, SLOT(showSource()));
+ connect(textInput, &QLineEdit::textChanged, m_renderer, &PathDeformRenderer::setText);
+ connect(m_renderer, &ArthurFrame::descriptionEnabledChanged,
+ whatsThisButton, &QAbstractButton::setChecked);
+ connect(whatsThisButton, &QAbstractButton::clicked, m_renderer, &ArthurFrame::setDescriptionEnabled);
+ connect(showSourceButton, &QAbstractButton::clicked, m_renderer, &ArthurFrame::showSource);
animateButton->animateClick();
deformSlider->setValue(80);
@@ -211,7 +211,7 @@ void PathDeformControls::layoutForSmallScreen()
QGridLayout *mainGroupLayout = new QGridLayout(mainGroup);
- mainGroupLayout->setMargin(0);
+ mainGroupLayout->setContentsMargins(QMargins());
mainGroupLayout->addWidget(radiusLabel, 0, 0, Qt::AlignRight);
mainGroupLayout->addWidget(radiusSlider, 0, 1);
mainGroupLayout->addWidget(deformLabel, 1, 0, Qt::AlignRight);
@@ -229,14 +229,14 @@ void PathDeformControls::layoutForSmallScreen()
mainLayout->addWidget(okButton);
mainLayout->addWidget(quitButton);
- connect(quitButton, SIGNAL(clicked()), this, SIGNAL(quitPressed()));
- connect(okButton, SIGNAL(clicked()), this, SIGNAL(okPressed()));
- connect(radiusSlider, SIGNAL(valueChanged(int)), m_renderer, SLOT(setRadius(int)));
- connect(deformSlider, SIGNAL(valueChanged(int)), m_renderer, SLOT(setIntensity(int)));
- connect(fontSizeSlider, SIGNAL(valueChanged(int)), m_renderer, SLOT(setFontSize(int)));
- connect(animateButton, SIGNAL(clicked(bool)), m_renderer, SLOT(setAnimated(bool)));
+ connect(quitButton, &QAbstractButton::clicked, this, &PathDeformControls::quitPressed);
+ connect(okButton, &QAbstractButton::clicked, this, &PathDeformControls::okPressed);
+ connect(radiusSlider, &QAbstractSlider::valueChanged, m_renderer, &PathDeformRenderer::setRadius);
+ connect(deformSlider, &QAbstractSlider::valueChanged, m_renderer, &PathDeformRenderer::setIntensity);
+ connect(fontSizeSlider, &QAbstractSlider::valueChanged, m_renderer, &PathDeformRenderer::setFontSize);
+ connect(animateButton, &QAbstractButton::clicked, m_renderer, &PathDeformRenderer::setAnimated);
#if QT_CONFIG(opengl)
- connect(enableOpenGLButton, SIGNAL(clicked(bool)), m_renderer, SLOT(enableOpenGL(bool)));
+ connect(enableOpenGLButton, &QAbstractButton::clicked, m_renderer, &ArthurFrame::enableOpenGL);
#endif
@@ -272,9 +272,12 @@ PathDeformWidget::PathDeformWidget(QWidget *parent, bool smallScreen)
m_renderer->loadDescription(":res/deform/pathdeform.html");
m_renderer->setDescriptionEnabled(false);
- connect(m_renderer, SIGNAL(clicked()), this, SLOT(showControls()));
- connect(m_controls, SIGNAL(okPressed()), this, SLOT(hideControls()));
- connect(m_controls, SIGNAL(quitPressed()), QCoreApplication::instance(), SLOT(quit()));
+ connect(m_renderer, &PathDeformRenderer::clicked,
+ this, &PathDeformWidget::showControls);
+ connect(m_controls, &PathDeformControls::okPressed,
+ this, &PathDeformWidget::hideControls);
+ connect(m_controls, &PathDeformControls::quitPressed,
+ qApp, &QCoreApplication::quit);
}
@@ -288,16 +291,16 @@ void PathDeformWidget::hideControls()
m_controls->hide();
}
-void PathDeformWidget::setStyle( QStyle * style )
+void PathDeformWidget::setStyle(QStyle *style)
{
QWidget::setStyle(style);
- if (m_controls == 0)
+ if (!m_controls)
return;
m_controls->setStyle(style);
- QList<QWidget *> widgets = m_controls->findChildren<QWidget *>();
- foreach (QWidget *w, widgets)
+ const QList<QWidget *> widgets = m_controls->findChildren<QWidget *>();
+ for (QWidget *w : widgets)
w->setStyle(style);
}
diff --git a/examples/widgets/painting/deform/pathdeform.h b/examples/widgets/painting/deform/pathdeform.h
index 68908045b9..b7c7386e2a 100644
--- a/examples/widgets/painting/deform/pathdeform.h
+++ b/examples/widgets/painting/deform/pathdeform.h
@@ -135,7 +135,7 @@ signals:
void okPressed();
void quitPressed();
private:
- PathDeformRenderer* m_renderer;
+ PathDeformRenderer *m_renderer;
void layoutForDesktop();
void layoutForSmallScreen();
};
@@ -145,7 +145,7 @@ class PathDeformWidget : public QWidget
Q_OBJECT
public:
PathDeformWidget(QWidget *parent, bool smallScreen);
- void setStyle (QStyle * style );
+ void setStyle(QStyle *style);
private:
PathDeformRenderer *m_renderer;
diff --git a/examples/widgets/painting/fontsampler/mainwindow.cpp b/examples/widgets/painting/fontsampler/mainwindow.cpp
index bd15438df9..b3304b4b6d 100644
--- a/examples/widgets/painting/fontsampler/mainwindow.cpp
+++ b/examples/widgets/painting/fontsampler/mainwindow.cpp
@@ -71,13 +71,14 @@ MainWindow::MainWindow(QWidget *parent)
markedCount = 0;
setupFontTree();
- connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit()));
- connect(fontTree, SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)),
- this, SLOT(showFont(QTreeWidgetItem*)));
- connect(fontTree, SIGNAL(itemChanged(QTreeWidgetItem*,int)),
- this, SLOT(updateStyles(QTreeWidgetItem*,int)));
-
- fontTree->setItemSelected(fontTree->topLevelItem(0), true);
+ connect(quitAction, &QAction::triggered,
+ qApp, &QApplication::quit);
+ connect(fontTree, &QTreeWidget::currentItemChanged,
+ this, &MainWindow::showFont);
+ connect(fontTree, &QTreeWidget::itemChanged,
+ this, &MainWindow::updateStyles);
+
+ fontTree->topLevelItem(0)->setSelected(true);
showFont(fontTree->topLevelItem(0));
}
@@ -85,9 +86,10 @@ void MainWindow::setupFontTree()
{
QFontDatabase database;
fontTree->setColumnCount(1);
- fontTree->setHeaderLabels(QStringList() << tr("Font"));
+ fontTree->setHeaderLabels({ tr("Font") });
- foreach (QString family, database.families()) {
+ const QStringList fontFamilies = database.families();
+ for (const QString &family : fontFamilies) {
const QStringList styles = database.styles(family);
if (styles.isEmpty())
continue;
@@ -97,7 +99,7 @@ void MainWindow::setupFontTree()
familyItem->setCheckState(0, Qt::Unchecked);
familyItem->setFlags(familyItem->flags() | Qt::ItemIsAutoTristate);
- foreach (QString style, styles) {
+ for (const QString &style : styles) {
QTreeWidgetItem *styleItem = new QTreeWidgetItem(familyItem);
styleItem->setText(0, style);
styleItem->setCheckState(0, Qt::Unchecked);
@@ -109,10 +111,10 @@ void MainWindow::setupFontTree()
void MainWindow::on_clearAction_triggered()
{
- QTreeWidgetItem *currentItem = fontTree->currentItem();
- foreach (QTreeWidgetItem *item, fontTree->selectedItems())
- fontTree->setItemSelected(item, false);
- fontTree->setItemSelected(currentItem, true);
+ const QList<QTreeWidgetItem *> items = fontTree->selectedItems();
+ for (QTreeWidgetItem *item : items)
+ item->setSelected(false);
+ fontTree->currentItem()->setSelected(true);
}
void MainWindow::on_markAction_triggered()
@@ -127,8 +129,8 @@ void MainWindow::on_unmarkAction_triggered()
void MainWindow::markUnmarkFonts(Qt::CheckState state)
{
- QList<QTreeWidgetItem *> items = fontTree->selectedItems();
- foreach (QTreeWidgetItem *item, items) {
+ const QList<QTreeWidgetItem *> items = fontTree->selectedItems();
+ for (QTreeWidgetItem *item : items) {
if (item->checkState(0) != state)
item->setCheckState(0, state);
}
@@ -285,8 +287,8 @@ void MainWindow::on_printPreviewAction_triggered()
QPrinter printer(QPrinter::HighResolution);
QPrintPreviewDialog preview(&printer, this);
- connect(&preview, SIGNAL(paintRequested(QPrinter*)),
- this, SLOT(printDocument(QPrinter*)));
+ connect(&preview, &QPrintPreviewDialog::paintRequested,
+ this, &MainWindow::printDocument);
preview.exec();
#endif
}
@@ -294,19 +296,19 @@ void MainWindow::on_printPreviewAction_triggered()
void MainWindow::printPage(int index, QPainter *painter, QPrinter *printer)
{
#if defined(QT_PRINTSUPPORT_LIB) && QT_CONFIG(printdialog)
- QString family = pageMap.keys()[index];
- StyleItems items = pageMap[family];
+ const QString family = (pageMap.begin() + index).key();
+ const StyleItems items = pageMap.value(family);
// Find the dimensions of the text on each page.
qreal width = 0.0;
qreal height = 0.0;
- foreach (QTreeWidgetItem *item, items) {
+ for (const QTreeWidgetItem *item : items) {
QString style = item->text(0);
int weight = item->data(0, Qt::UserRole).toInt();
bool italic = item->data(0, Qt::UserRole + 1).toBool();
// Calculate the maximum width and total height of the text.
- foreach (int size, sampleSizes) {
+ for (int size : qAsConst(sampleSizes)) {
QFont font(family, size, weight, italic);
font.setStyleName(style);
font = QFont(font, painter->device());
@@ -334,13 +336,13 @@ void MainWindow::printPage(int index, QPainter *painter, QPrinter *printer)
qreal x = -width / 2.0;
qreal y = -height / 2.0 - remainingHeight / 4.0 + spaceHeight;
- foreach (QTreeWidgetItem *item, items) {
+ for (const QTreeWidgetItem *item : items) {
QString style = item->text(0);
int weight = item->data(0, Qt::UserRole).toInt();
bool italic = item->data(0, Qt::UserRole + 1).toBool();
// Draw each line of text.
- foreach (int size, sampleSizes) {
+ for (int size : qAsConst(sampleSizes)) {
QFont font(family, size, weight, italic);
font.setStyleName(style);
font = QFont(font, painter->device());
diff --git a/examples/widgets/painting/gradients/gradients.cpp b/examples/widgets/painting/gradients/gradients.cpp
index 004f6710cd..7abaef771b 100644
--- a/examples/widgets/painting/gradients/gradients.cpp
+++ b/examples/widgets/painting/gradients/gradients.cpp
@@ -180,7 +180,7 @@ GradientEditor::GradientEditor(QWidget *parent)
{
QVBoxLayout *vbox = new QVBoxLayout(this);
vbox->setSpacing(1);
- vbox->setMargin(1);
+ vbox->setContentsMargins(1, 1, 1, 1);
m_red_shade = new ShadeWidget(ShadeWidget::RedShade, this);
m_green_shade = new ShadeWidget(ShadeWidget::GreenShade, this);
@@ -421,7 +421,7 @@ GradientWidget::GradientWidget(QWidget *parent)
m_renderer->loadSourceFile(":res/gradients/gradients.cpp");
m_renderer->loadDescription(":res/gradients/gradients.html");
- QTimer::singleShot(50, this, SLOT(setDefault1()));
+ QTimer::singleShot(50, this, &GradientWidget::setDefault1);
}
void GradientWidget::setDefault(int config)
diff --git a/examples/widgets/painting/gradients/main.cpp b/examples/widgets/painting/gradients/main.cpp
index 6c5261fe6b..539d67e40e 100644
--- a/examples/widgets/painting/gradients/main.cpp
+++ b/examples/widgets/painting/gradients/main.cpp
@@ -61,8 +61,8 @@ int main(int argc, char *argv[])
GradientWidget gradientWidget(0);
QStyle *arthurStyle = new ArthurStyle();
gradientWidget.setStyle(arthurStyle);
- QList<QWidget *> widgets = gradientWidget.findChildren<QWidget *>();
- foreach (QWidget *w, widgets) {
+ const QList<QWidget *> widgets = gradientWidget.findChildren<QWidget *>();
+ for (QWidget *w : widgets) {
w->setStyle(arthurStyle);
w->setAttribute(Qt::WA_AcceptTouchEvents);
}
diff --git a/examples/widgets/painting/imagecomposition/imagecomposer.cpp b/examples/widgets/painting/imagecomposition/imagecomposer.cpp
index d53017b955..ffdc8f433c 100644
--- a/examples/widgets/painting/imagecomposition/imagecomposer.cpp
+++ b/examples/widgets/painting/imagecomposition/imagecomposer.cpp
@@ -100,9 +100,12 @@ ImageComposer::ImageComposer()
//! [2]
//! [3]
- connect(sourceButton, SIGNAL(clicked()), this, SLOT(chooseSource()));
- connect(operatorComboBox, SIGNAL(activated(int)), this, SLOT(recalculateResult()));
- connect(destinationButton, SIGNAL(clicked()), this, SLOT(chooseDestination()));
+ connect(sourceButton, &QAbstractButton::clicked,
+ this, &ImageComposer::chooseSource);
+ connect(operatorComboBox, QOverload<int>::of(&QComboBox::activated),
+ this, &ImageComposer::recalculateResult);
+ connect(destinationButton, &QAbstractButton::clicked,
+ this, &ImageComposer::chooseDestination);
//! [3]
//! [4]
diff --git a/examples/widgets/painting/painterpaths/window.cpp b/examples/widgets/painting/painterpaths/window.cpp
index a987937b39..6fb3218313 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,16 +272,16 @@ 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]
//! [22]
void Window::populateWithColors(QComboBox *comboBox)
{
- QStringList colorNames = QColor::colorNames();
- foreach (QString name, colorNames)
+ const QStringList colorNames = QColor::colorNames();
+ for (const QString &name : colorNames)
comboBox->addItem(name, QColor(name));
}
//! [22]
diff --git a/examples/widgets/painting/pathstroke/main.cpp b/examples/widgets/painting/pathstroke/main.cpp
index 3a63203118..57c85d73a3 100644
--- a/examples/widgets/painting/pathstroke/main.cpp
+++ b/examples/widgets/painting/pathstroke/main.cpp
@@ -63,8 +63,8 @@ int main(int argc, char **argv)
PathStrokeWidget pathStrokeWidget(smallScreen);
QStyle *arthurStyle = new ArthurStyle();
pathStrokeWidget.setStyle(arthurStyle);
- QList<QWidget *> widgets = pathStrokeWidget.findChildren<QWidget *>();
- foreach (QWidget *w, widgets) {
+ const QList<QWidget *> widgets = pathStrokeWidget.findChildren<QWidget *>();
+ for (QWidget *w : widgets) {
w->setStyle(arthurStyle);
w->setAttribute(Qt::WA_AcceptTouchEvents);
}
diff --git a/examples/widgets/painting/pathstroke/pathstroke.cpp b/examples/widgets/painting/pathstroke/pathstroke.cpp
index b04998afac..03e55bb2a2 100644
--- a/examples/widgets/painting/pathstroke/pathstroke.cpp
+++ b/examples/widgets/painting/pathstroke/pathstroke.cpp
@@ -164,24 +164,24 @@ void PathStrokeControls::createCommonControls(QWidget* parent)
// Connections
- connect(flatCap, SIGNAL(clicked()), m_renderer, SLOT(setFlatCap()));
- connect(squareCap, SIGNAL(clicked()), m_renderer, SLOT(setSquareCap()));
- connect(roundCap, SIGNAL(clicked()), m_renderer, SLOT(setRoundCap()));
+ connect(flatCap, &QAbstractButton::clicked, m_renderer, &PathStrokeRenderer::setFlatCap);
+ connect(squareCap, &QAbstractButton::clicked, m_renderer, &PathStrokeRenderer::setSquareCap);
+ connect(roundCap, &QAbstractButton::clicked, m_renderer, &PathStrokeRenderer::setRoundCap);
- connect(bevelJoin, SIGNAL(clicked()), m_renderer, SLOT(setBevelJoin()));
- connect(miterJoin, SIGNAL(clicked()), m_renderer, SLOT(setMiterJoin()));
- connect(svgMiterJoin, SIGNAL(clicked()), m_renderer, SLOT(setSvgMiterJoin()));
- connect(roundJoin, SIGNAL(clicked()), m_renderer, SLOT(setRoundJoin()));
+ connect(bevelJoin, &QAbstractButton::clicked, m_renderer, &PathStrokeRenderer::setBevelJoin);
+ connect(miterJoin, &QAbstractButton::clicked, m_renderer, &PathStrokeRenderer::setMiterJoin);
+ connect(svgMiterJoin, &QAbstractButton::clicked, m_renderer, &PathStrokeRenderer::setSvgMiterJoin);
+ connect(roundJoin, &QAbstractButton::clicked, m_renderer, &PathStrokeRenderer::setRoundJoin);
- connect(curveMode, SIGNAL(clicked()), m_renderer, SLOT(setCurveMode()));
- connect(lineMode, SIGNAL(clicked()), m_renderer, SLOT(setLineMode()));
+ connect(curveMode, &QAbstractButton::clicked, m_renderer, &PathStrokeRenderer::setCurveMode);
+ connect(lineMode, &QAbstractButton::clicked, m_renderer, &PathStrokeRenderer::setLineMode);
- connect(solidLine, SIGNAL(clicked()), m_renderer, SLOT(setSolidLine()));
- connect(dashLine, SIGNAL(clicked()), m_renderer, SLOT(setDashLine()));
- connect(dotLine, SIGNAL(clicked()), m_renderer, SLOT(setDotLine()));
- connect(dashDotLine, SIGNAL(clicked()), m_renderer, SLOT(setDashDotLine()));
- connect(dashDotDotLine, SIGNAL(clicked()), m_renderer, SLOT(setDashDotDotLine()));
- connect(customDashLine, SIGNAL(clicked()), m_renderer, SLOT(setCustomDashLine()));
+ connect(solidLine, &QAbstractButton::clicked, m_renderer, &PathStrokeRenderer::setSolidLine);
+ connect(dashLine, &QAbstractButton::clicked, m_renderer, &PathStrokeRenderer::setDashLine);
+ connect(dotLine, &QAbstractButton::clicked, m_renderer, &PathStrokeRenderer::setDotLine);
+ connect(dashDotLine, &QAbstractButton::clicked, m_renderer, &PathStrokeRenderer::setDashDotLine);
+ connect(dashDotDotLine, &QAbstractButton::clicked, m_renderer, &PathStrokeRenderer::setDashDotDotLine);
+ connect(customDashLine, &QAbstractButton::clicked, m_renderer, &PathStrokeRenderer::setCustomDashLine);
// Set the defaults:
flatCap->setChecked(true);
@@ -227,11 +227,11 @@ void PathStrokeControls::layoutForDesktop()
penWidthLayout->addWidget(penWidth);
QVBoxLayout * mainLayout = new QVBoxLayout(this);
- mainLayout->setMargin(0);
+ mainLayout->setContentsMargins(QMargins());
mainLayout->addWidget(mainGroup);
QVBoxLayout *mainGroupLayout = new QVBoxLayout(mainGroup);
- mainGroupLayout->setMargin(3);
+ mainGroupLayout->setContentsMargins(3, 3, 3, 3);
mainGroupLayout->addWidget(m_capGroup);
mainGroupLayout->addWidget(m_joinGroup);
mainGroupLayout->addWidget(m_styleGroup);
@@ -247,17 +247,17 @@ void PathStrokeControls::layoutForDesktop()
// Set up connections
- connect(animated, SIGNAL(toggled(bool)), m_renderer, SLOT(setAnimation(bool)));
+ connect(animated, &QAbstractButton::toggled, m_renderer, &PathStrokeRenderer::setAnimation);
- connect(penWidth, SIGNAL(valueChanged(int)), m_renderer, SLOT(setPenWidth(int)));
+ connect(penWidth, &QAbstractSlider::valueChanged, m_renderer, &PathStrokeRenderer::setPenWidth);
- connect(showSourceButton, SIGNAL(clicked()), m_renderer, SLOT(showSource()));
+ connect(showSourceButton, &QAbstractButton::clicked, m_renderer, &ArthurFrame::showSource);
#if QT_CONFIG(opengl)
- connect(enableOpenGLButton, SIGNAL(clicked(bool)), m_renderer, SLOT(enableOpenGL(bool)));
+ connect(enableOpenGLButton, &QAbstractButton::clicked, m_renderer, &ArthurFrame::enableOpenGL);
#endif
- connect(whatsThisButton, SIGNAL(clicked(bool)), m_renderer, SLOT(setDescriptionEnabled(bool)));
- connect(m_renderer, SIGNAL(descriptionEnabledChanged(bool)),
- whatsThisButton, SLOT(setChecked(bool)));
+ connect(whatsThisButton, &QAbstractButton::clicked, m_renderer, &ArthurFrame::setDescriptionEnabled);
+ connect(m_renderer, &ArthurFrame::descriptionEnabledChanged,
+ whatsThisButton, &QAbstractButton::setChecked);
// Set the defaults
@@ -270,10 +270,10 @@ void PathStrokeControls::layoutForSmallScreens()
{
createCommonControls(this);
- m_capGroup->layout()->setMargin(0);
- m_joinGroup->layout()->setMargin(0);
- m_styleGroup->layout()->setMargin(0);
- m_pathModeGroup->layout()->setMargin(0);
+ m_capGroup->layout()->setContentsMargins(QMargins());
+ m_joinGroup->layout()->setContentsMargins(QMargins());
+ m_styleGroup->layout()->setContentsMargins(QMargins());
+ m_pathModeGroup->layout()->setContentsMargins(QMargins());
QPushButton* okBtn = new QPushButton(tr("OK"), this);
okBtn->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
@@ -313,7 +313,7 @@ void PathStrokeControls::layoutForSmallScreens()
rightLayout->addWidget(m_pathModeGroup);
QGridLayout *mainLayout = new QGridLayout(this);
- mainLayout->setMargin(0);
+ mainLayout->setContentsMargins(QMargins());
// Add spacers around the form items so we don't look stupid at higher resolutions
mainLayout->addItem(new QSpacerItem(0,0), 0, 0, 1, 4);
@@ -327,12 +327,12 @@ void PathStrokeControls::layoutForSmallScreens()
mainLayout->addWidget(okBtn, 2, 2, Qt::AlignHCenter | Qt::AlignTop);
#if QT_CONFIG(opengl)
- connect(enableOpenGLButton, SIGNAL(clicked(bool)), m_renderer, SLOT(enableOpenGL(bool)));
+ connect(enableOpenGLButton, &QAbstractButton::clicked, m_renderer, &ArthurFrame::enableOpenGL);
#endif
- connect(penWidth, SIGNAL(valueChanged(int)), m_renderer, SLOT(setPenWidth(int)));
- connect(quitBtn, SIGNAL(clicked()), this, SLOT(emitQuitSignal()));
- connect(okBtn, SIGNAL(clicked()), this, SLOT(emitOkSignal()));
+ connect(penWidth, &QAbstractSlider::valueChanged, m_renderer, &PathStrokeRenderer::setPenWidth);
+ connect(quitBtn, &QAbstractButton::clicked, this, &PathStrokeControls::emitQuitSignal);
+ connect(okBtn, &QAbstractButton::clicked, this, &PathStrokeControls::emitOkSignal);
m_renderer->setAnimation(true);
penWidth->setValue(50);
@@ -368,8 +368,8 @@ PathStrokeWidget::PathStrokeWidget(bool smallScreen)
m_renderer->loadSourceFile(":res/pathstroke/pathstroke.cpp");
m_renderer->loadDescription(":res/pathstroke/pathstroke.html");
- connect(m_renderer, SIGNAL(clicked()), this, SLOT(showControls()));
- connect(m_controls, SIGNAL(okPressed()), this, SLOT(hideControls()));
+ connect(m_renderer, &PathStrokeRenderer::clicked, this, &PathStrokeWidget::showControls);
+ connect(m_controls, &PathStrokeControls::okPressed, this, &PathStrokeWidget::hideControls);
connect(m_controls, SIGNAL(quitPressed()), QApplication::instance(), SLOT(quit()));
}
@@ -390,8 +390,8 @@ void PathStrokeWidget::setStyle( QStyle * style )
{
m_controls->setStyle(style);
- QList<QWidget *> widgets = m_controls->findChildren<QWidget *>();
- foreach (QWidget *w, widgets)
+ const QList<QWidget *> widgets = m_controls->findChildren<QWidget *>();
+ for (QWidget *w : widgets)
w->setStyle(style);
}
}
@@ -605,7 +605,7 @@ bool PathStrokeRenderer::event(QEvent *e)
{
const QTouchEvent *const event = static_cast<const QTouchEvent*>(e);
const QList<QTouchEvent::TouchPoint> points = event->touchPoints();
- foreach (const QTouchEvent::TouchPoint &touchPoint, points) {
+ for (const QTouchEvent::TouchPoint &touchPoint : points) {
const int id = touchPoint.id();
switch (touchPoint.state()) {
case Qt::TouchPointPressed:
diff --git a/examples/widgets/painting/shared/arthurstyle.cpp b/examples/widgets/painting/shared/arthurstyle.cpp
index f4fc76bda6..3fc461bbd2 100644
--- a/examples/widgets/painting/shared/arthurstyle.cpp
+++ b/examples/widgets/painting/shared/arthurstyle.cpp
@@ -61,10 +61,10 @@
QPixmap cached(const QString &img)
{
- if (QPixmap *p = QPixmapCache::find(img))
- return *p;
-
QPixmap pm;
+ if (QPixmapCache::find(img, &pm))
+ return pm;
+
pm = QPixmap::fromImage(QImage(img), Qt::OrderedDither | Qt::OrderedAlphaDither);
if (pm.isNull())
return QPixmap();
@@ -443,9 +443,9 @@ void ArthurStyle::polish(QWidget *widget)
if (widget->layout() && qobject_cast<QGroupBox *>(widget)) {
if (widget->findChildren<QGroupBox *>().size() == 0) {
widget->layout()->setSpacing(0);
- widget->layout()->setMargin(12);
+ widget->layout()->setContentsMargins(12, 12, 12, 12);
} else {
- widget->layout()->setMargin(13);
+ widget->layout()->setContentsMargins(13, 13, 13, 13);
}
}
diff --git a/examples/widgets/painting/shared/arthurwidgets.cpp b/examples/widgets/painting/shared/arthurwidgets.cpp
index 442fb69ac1..bdac5de13c 100644
--- a/examples/widgets/painting/shared/arthurwidgets.cpp
+++ b/examples/widgets/painting/shared/arthurwidgets.cpp
@@ -330,32 +330,40 @@ void ArthurFrame::showSource()
QString contents;
if (m_sourceFileName.isEmpty()) {
- contents = QString("No source for widget: '%1'").arg(objectName());
+ contents = tr("No source for widget: '%1'").arg(objectName());
} else {
QFile f(m_sourceFileName);
if (!f.open(QFile::ReadOnly))
- contents = QString("Could not open file: '%1'").arg(m_sourceFileName);
+ contents = tr("Could not open file: '%1'").arg(m_sourceFileName);
else
contents = f.readAll();
}
- contents.replace('&', "&amp;");
- contents.replace('<', "&lt;");
- contents.replace('>', "&gt;");
-
- QStringList keywords;
- keywords << "for " << "if " << "switch " << " int " << "#include " << "const"
- << "void " << "uint " << "case " << "double " << "#define " << "static"
- << "new" << "this";
-
- foreach (QString keyword, keywords)
+ contents.replace(QLatin1Char('&'), QStringLiteral("&amp;"));
+ contents.replace(QLatin1Char('<'), QStringLiteral("&lt;"));
+ contents.replace(QLatin1Char('>'), QStringLiteral("&gt;"));
+
+ static const QString keywords[] = {
+ QStringLiteral("for "), QStringLiteral("if "),
+ QStringLiteral("switch "), QStringLiteral(" int "),
+ QStringLiteral("#include "), QStringLiteral("const"),
+ QStringLiteral("void "), QStringLiteral("uint "),
+ QStringLiteral("case "), QStringLiteral("double "),
+ QStringLiteral("#define "), QStringLiteral("static"),
+ QStringLiteral("new"), QStringLiteral("this")
+ };
+
+ for (const QString &keyword : keywords)
contents.replace(keyword, QLatin1String("<font color=olive>") + keyword + QLatin1String("</font>"));
- contents.replace("(int ", "(<font color=olive><b>int </b></font>");
+ contents.replace(QStringLiteral("(int "), QStringLiteral("(<font color=olive><b>int </b></font>"));
- QStringList ppKeywords;
- ppKeywords << "#ifdef" << "#ifndef" << "#if" << "#endif" << "#else";
+ static const QString ppKeywords[] = {
+ QStringLiteral("#ifdef"), QStringLiteral("#ifndef"),
+ QStringLiteral("#if"), QStringLiteral("#endif"),
+ QStringLiteral("#else")
+ };
- foreach (QString keyword, ppKeywords)
+ for (const QString &keyword : ppKeywords)
contents.replace(keyword, QLatin1String("<font color=navy>") + keyword + QLatin1String("</font>"));
contents.replace(QRegularExpression("(\\d\\d?)"), QLatin1String("<font color=navy>\\1</font>"));
@@ -366,12 +374,10 @@ void ArthurFrame::showSource()
QRegularExpression stringLiteralRe("(\".+?\")");
contents.replace(stringLiteralRe, QLatin1String("<font color=green>\\1</font>"));
- QString html = contents;
- html.prepend("<html><pre>");
- html.append("</pre></html>");
+ const QString html = QStringLiteral("<html><pre>") + contents + QStringLiteral("</pre></html>");
QTextBrowser *sourceViewer = new QTextBrowser(0);
- sourceViewer->setWindowTitle("Source: " + m_sourceFileName.mid(5));
+ sourceViewer->setWindowTitle(tr("Source: %1").arg(m_sourceFileName.midRef(5)));
sourceViewer->setParent(this, Qt::Dialog);
sourceViewer->setAttribute(Qt::WA_DeleteOnClose);
sourceViewer->setLineWrapMode(QTextEdit::NoWrap);
diff --git a/examples/widgets/painting/shared/hoverpoints.cpp b/examples/widgets/painting/shared/hoverpoints.cpp
index 7cd8cc0b29..74c78088ad 100644
--- a/examples/widgets/painting/shared/hoverpoints.cpp
+++ b/examples/widgets/painting/shared/hoverpoints.cpp
@@ -73,8 +73,8 @@ HoverPoints::HoverPoints(QWidget *widget, PointShape shape)
m_editable = true;
m_enabled = true;
- connect(this, SIGNAL(pointsChanged(QPolygonF)),
- m_widget, SLOT(update()));
+ connect(this, &HoverPoints::pointsChanged,
+ m_widget, QOverload<>::of(&QWidget::update));
}
@@ -174,7 +174,7 @@ bool HoverPoints::eventFilter(QObject *object, QEvent *event)
const QTouchEvent *const touchEvent = static_cast<const QTouchEvent*>(event);
const QList<QTouchEvent::TouchPoint> points = touchEvent->touchPoints();
const qreal pointSize = qMax(m_pointSize.width(), m_pointSize.height());
- foreach (const QTouchEvent::TouchPoint &touchPoint, points) {
+ for (const QTouchEvent::TouchPoint &touchPoint : points) {
const int id = touchPoint.id();
switch (touchPoint.state()) {
case Qt::TouchPointPressed:
diff --git a/examples/widgets/painting/transformations/window.cpp b/examples/widgets/painting/transformations/window.cpp
index d8babb2e00..8261c4e12e 100644
--- a/examples/widgets/painting/transformations/window.cpp
+++ b/examples/widgets/painting/transformations/window.cpp
@@ -79,8 +79,8 @@ Window::Window()
operationComboBoxes[i]->addItem(tr("Scale to 75%"));
operationComboBoxes[i]->addItem(tr("Translate by (50, 50)"));
- connect(operationComboBoxes[i], SIGNAL(activated(int)),
- this, SLOT(operationChanged()));
+ connect(operationComboBoxes[i], QOverload<int>::of(&QComboBox::activated),
+ this, &Window::operationChanged);
layout->addWidget(transformedRenderAreas[i], 0, i + 1);
layout->addWidget(operationComboBoxes[i], 1, i + 1);
@@ -159,7 +159,8 @@ void Window::setupShapes()
shapes.append(text);
shapes.append(truck);
- connect(shapeComboBox, SIGNAL(activated(int)), this, SLOT(shapeSelected(int)));
+ connect(shapeComboBox, QOverload<int>::of(&QComboBox::activated),
+ this, &Window::shapeSelected);
}
//! [7]