diff --git a/examples/network/securesocketclient/sslclient.cpp b/examples/network/securesocketclient/sslclient.cpp index afeec033ff..79ed7746d6 100644 --- a/examples/network/securesocketclient/sslclient.cpp +++ b/examples/network/securesocketclient/sslclient.cpp @@ -206,7 +206,8 @@ void SslClient::setupUi() padLock->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Ignored); QHBoxLayout *layout = new QHBoxLayout(form->hostNameEdit); - layout->setMargin(form->hostNameEdit->style()->pixelMetric(QStyle::PM_DefaultFrameWidth)); + const int margin = form->hostNameEdit->style()->pixelMetric(QStyle::PM_DefaultFrameWidth); + layout->setContentsMargins(margin, margin, margin, margin); layout->setSpacing(0); layout->addStretch(); layout->addWidget(padLock); diff --git a/examples/network/torrent/mainwindow.cpp b/examples/network/torrent/mainwindow.cpp index 39b166101d..704012ef6d 100644 --- a/examples/network/torrent/mainwindow.cpp +++ b/examples/network/torrent/mainwindow.cpp @@ -630,7 +630,7 @@ void MainWindow::about() QPushButton *quitButton = new QPushButton("OK"); QHBoxLayout *topLayout = new QHBoxLayout; - topLayout->setMargin(10); + topLayout->setContentsMargins(10, 10, 10, 10); topLayout->setSpacing(10); topLayout->addWidget(icon); topLayout->addWidget(text); diff --git a/examples/widgets/dialogs/extension/finddialog.cpp b/examples/widgets/dialogs/extension/finddialog.cpp index 1321155f00..10a4ae1ac0 100644 --- a/examples/widgets/dialogs/extension/finddialog.cpp +++ b/examples/widgets/dialogs/extension/finddialog.cpp @@ -91,7 +91,7 @@ FindDialog::FindDialog(QWidget *parent) connect(moreButton, &QAbstractButton::toggled, extension, &QWidget::setVisible); QVBoxLayout *extensionLayout = new QVBoxLayout; - extensionLayout->setMargin(0); + extensionLayout->setContentsMargins(QMargins()); extensionLayout->addWidget(wholeWordsCheckBox); extensionLayout->addWidget(backwardCheckBox); extensionLayout->addWidget(searchSelectionCheckBox); diff --git a/examples/widgets/layouts/borderlayout/borderlayout.cpp b/examples/widgets/layouts/borderlayout/borderlayout.cpp index c929d3b2a4..b8ddd3af83 100644 --- a/examples/widgets/layouts/borderlayout/borderlayout.cpp +++ b/examples/widgets/layouts/borderlayout/borderlayout.cpp @@ -50,10 +50,10 @@ #include "borderlayout.h" -BorderLayout::BorderLayout(QWidget *parent, int margin, int spacing) +BorderLayout::BorderLayout(QWidget *parent, const QMargins &margins, int spacing) : QLayout(parent) { - setMargin(margin); + setContentsMargins(margins); setSpacing(spacing); } diff --git a/examples/widgets/layouts/borderlayout/borderlayout.h b/examples/widgets/layouts/borderlayout/borderlayout.h index 4c0c01f90b..58d1aa394d 100644 --- a/examples/widgets/layouts/borderlayout/borderlayout.h +++ b/examples/widgets/layouts/borderlayout/borderlayout.h @@ -59,7 +59,7 @@ class BorderLayout : public QLayout public: enum Position { West, North, South, East, Center }; - explicit BorderLayout(QWidget *parent, int margin = 0, int spacing = -1); + explicit BorderLayout(QWidget *parent, const QMargins &margins = QMargins(), int spacing = -1); BorderLayout(int spacing = -1); ~BorderLayout(); diff --git a/examples/widgets/layouts/flowlayout/flowlayout.cpp b/examples/widgets/layouts/flowlayout/flowlayout.cpp index 53613b8b20..5c59ae025c 100644 --- a/examples/widgets/layouts/flowlayout/flowlayout.cpp +++ b/examples/widgets/layouts/flowlayout/flowlayout.cpp @@ -158,7 +158,8 @@ QSize FlowLayout::minimumSize() const for (const QLayoutItem *item : qAsConst(itemList)) size = size.expandedTo(item->minimumSize()); - size += QSize(2*margin(), 2*margin()); + const QMargins margins = contentsMargins(); + size += QSize(margins.left() + margins.right(), margins.top() + margins.bottom()); return size; } //! [8] diff --git a/examples/widgets/mainwindows/menus/mainwindow.cpp b/examples/widgets/mainwindows/menus/mainwindow.cpp index 600b04fdb2..c6aba8be83 100644 --- a/examples/widgets/mainwindows/menus/mainwindow.cpp +++ b/examples/widgets/mainwindows/menus/mainwindow.cpp @@ -72,7 +72,7 @@ MainWindow::MainWindow() bottomFiller->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); QVBoxLayout *layout = new QVBoxLayout; - layout->setMargin(5); + layout->setContentsMargins(5, 5, 5, 5); layout->addWidget(topFiller); layout->addWidget(infoLabel); layout->addWidget(bottomFiller); diff --git a/examples/widgets/painting/deform/pathdeform.cpp b/examples/widgets/painting/deform/pathdeform.cpp index 0eda76a831..64e81f8cab 100644 --- a/examples/widgets/painting/deform/pathdeform.cpp +++ b/examples/widgets/painting/deform/pathdeform.cpp @@ -150,7 +150,7 @@ void PathDeformControls::layoutForDesktop() QVBoxLayout * mainLayout = new QVBoxLayout(this); mainLayout->addWidget(mainGroup); - mainLayout->setMargin(0); + mainLayout->setContentsMargins(QMargins()); connect(radiusSlider, &QAbstractSlider::valueChanged, m_renderer, &PathDeformRenderer::setRadius); connect(deformSlider, &QAbstractSlider::valueChanged, m_renderer, &PathDeformRenderer::setIntensity); @@ -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); diff --git a/examples/widgets/painting/fontsampler/mainwindow.cpp b/examples/widgets/painting/fontsampler/mainwindow.cpp index a464eee3ff..b3304b4b6d 100644 --- a/examples/widgets/painting/fontsampler/mainwindow.cpp +++ b/examples/widgets/painting/fontsampler/mainwindow.cpp @@ -78,7 +78,7 @@ MainWindow::MainWindow(QWidget *parent) connect(fontTree, &QTreeWidget::itemChanged, this, &MainWindow::updateStyles); - fontTree->setItemSelected(fontTree->topLevelItem(0), true); + fontTree->topLevelItem(0)->setSelected(true); showFont(fontTree->topLevelItem(0)); } diff --git a/examples/widgets/painting/gradients/gradients.cpp b/examples/widgets/painting/gradients/gradients.cpp index fd6eaeb0d9..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); diff --git a/examples/widgets/painting/pathstroke/pathstroke.cpp b/examples/widgets/painting/pathstroke/pathstroke.cpp index cad0b8732c..03e55bb2a2 100644 --- a/examples/widgets/painting/pathstroke/pathstroke.cpp +++ b/examples/widgets/painting/pathstroke/pathstroke.cpp @@ -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); @@ -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); diff --git a/examples/widgets/painting/shared/arthurstyle.cpp b/examples/widgets/painting/shared/arthurstyle.cpp index 3df9d9a6dc..3fc461bbd2 100644 --- a/examples/widgets/painting/shared/arthurstyle.cpp +++ b/examples/widgets/painting/shared/arthurstyle.cpp @@ -443,9 +443,9 @@ void ArthurStyle::polish(QWidget *widget) if (widget->layout() && qobject_cast(widget)) { if (widget->findChildren().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/statemachine/trafficlight/main.cpp b/examples/widgets/statemachine/trafficlight/main.cpp index b348d4f65d..1a7050c28d 100644 --- a/examples/widgets/statemachine/trafficlight/main.cpp +++ b/examples/widgets/statemachine/trafficlight/main.cpp @@ -146,13 +146,13 @@ QState *createLightState(LightWidget *light, int duration, QState *parent = 0) class TrafficLight : public QWidget { public: - TrafficLight(QWidget *parent = 0) + TrafficLight(QWidget *parent = nullptr) : QWidget(parent) { QVBoxLayout *vbox = new QVBoxLayout(this); - TrafficLightWidget *widget = new TrafficLightWidget(); + TrafficLightWidget *widget = new TrafficLightWidget; vbox->addWidget(widget); - vbox->setMargin(0); + vbox->setContentsMargins(QMargins()); QStateMachine *machine = new QStateMachine(this); QState *redGoingYellow = createLightState(widget->redLight(), 3000); diff --git a/examples/widgets/tools/regularexpression/regularexpressiondialog.cpp b/examples/widgets/tools/regularexpression/regularexpressiondialog.cpp index 8fbf143cbd..ea3cb00a02 100644 --- a/examples/widgets/tools/regularexpression/regularexpressiondialog.cpp +++ b/examples/widgets/tools/regularexpression/regularexpressiondialog.cpp @@ -376,7 +376,7 @@ QWidget *RegularExpressionDialog::setupLeftUi() QFormLayout *layout = new QFormLayout(container); layout->setFieldGrowthPolicy(QFormLayout::AllNonFixedFieldsGrow); - layout->setMargin(0); + layout->setContentsMargins(QMargins()); QLabel *regexpAndSubjectLabel = new QLabel(tr("

Regular expression and text input

")); layout->addRow(regexpAndSubjectLabel); @@ -448,7 +448,7 @@ QWidget *RegularExpressionDialog::setupRightUi() QFormLayout *layout = new QFormLayout(container); layout->setFieldGrowthPolicy(QFormLayout::AllNonFixedFieldsGrow); - layout->setMargin(0); + layout->setContentsMargins(QMargins()); QLabel *matchInfoLabel = new QLabel(tr("

Match information

")); layout->addRow(matchInfoLabel); diff --git a/examples/widgets/widgets/styles/widgetgallery.cpp b/examples/widgets/widgets/styles/widgetgallery.cpp index 7f4b7f39d4..f0a0336a94 100644 --- a/examples/widgets/widgets/styles/widgetgallery.cpp +++ b/examples/widgets/widgets/styles/widgetgallery.cpp @@ -212,7 +212,7 @@ void WidgetGallery::createBottomLeftTabWidget() tableWidget = new QTableWidget(10, 10); QHBoxLayout *tab1hbox = new QHBoxLayout; - tab1hbox->setMargin(5); + tab1hbox->setContentsMargins(5,5, 5, 5); tab1hbox->addWidget(tableWidget); tab1->setLayout(tab1hbox); @@ -227,7 +227,7 @@ void WidgetGallery::createBottomLeftTabWidget() "How I wonder what you are!\n")); QHBoxLayout *tab2hbox = new QHBoxLayout; - tab2hbox->setMargin(5); + tab2hbox->setContentsMargins(5, 5, 5, 5); tab2hbox->addWidget(textEdit); tab2->setLayout(tab2hbox);