Replace QWidget::margin() with QWidget::contentsMargins()

Replace deprecated QWidget::margin/setMargin() calls with
contentsMargin/setContentsMargins().

Change-Id: I7fe8056196d73d1be97446d40a438cd0b1a13817
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
bb10
Christian Ehrlicher 2019-02-09 14:41:46 +01:00
parent 7c254024f3
commit 3c907d0f4a
13 changed files with 29 additions and 24 deletions

View File

@ -331,7 +331,7 @@ void QPrintPreviewDialogPrivate::init(QPrinter *_printer)
QVBoxLayout *topLayout = new QVBoxLayout;
topLayout->addWidget(mw);
topLayout->setMargin(0);
topLayout->setContentsMargins(0, 0, 0, 0);
q->setLayout(topLayout);
QString caption = QCoreApplication::translate("QPrintPreviewDialog", "Print Preview");

View File

@ -1179,7 +1179,8 @@ QColorShower::QColorShower(QColorDialog *parent)
curQColor = Qt::white;
gl = new QGridLayout(this);
gl->setMargin(gl->spacing());
const int s = gl->spacing();
gl->setContentsMargins(s, s, s, s);
lab = new QColorShowLabel(this);
#ifdef QT_SMALL_COLORDIALOG
@ -1807,7 +1808,7 @@ void QColorDialogPrivate::initWidgets()
rightLay->addStretch();
cs = new QColorShower(q);
pickLay->setMargin(cs->gl->margin());
pickLay->setContentsMargins(cs->gl->contentsMargins());
QObject::connect(cs, SIGNAL(newCol(QRgb)), q, SLOT(_q_newColorTypedIn(QRgb)));
QObject::connect(cs, SIGNAL(currentColorChanged(QColor)),
q, SIGNAL(currentColorChanged(QColor)));
@ -1816,7 +1817,7 @@ void QColorDialogPrivate::initWidgets()
#else
rightLay->addWidget(cs);
if (leftLay)
leftLay->addSpacing(cs->gl->margin());
leftLay->addSpacing(cs->gl->contentsMargins().right());
#endif
buttons = new QDialogButtonBox(q);

View File

@ -113,7 +113,7 @@ public:
, copyAvailable(false)
{
QVBoxLayout *layout = new QVBoxLayout;
layout->setMargin(0);
layout->setContentsMargins(QMargins());
QFrame *line = new QFrame(this);
line->setFrameShape(QFrame::HLine);
line->setFrameShadow(QFrame::Sunken);

View File

@ -331,7 +331,7 @@ QWizardHeader::QWizardHeader(QWidget *parent)
titleLabel->setFont(font);
layout = new QGridLayout(this);
layout->setMargin(0);
layout->setContentsMargins(QMargins());
layout->setSpacing(0);
layout->setRowMinimumHeight(3, 1);
@ -1032,13 +1032,13 @@ void QWizardPrivate::recreateLayout(const QWizardLayoutInfo &info)
int pageColumn = qMin(1, numColumns - 1);
if (mac) {
mainLayout->setMargin(0);
mainLayout->setContentsMargins(QMargins());
mainLayout->setSpacing(0);
buttonLayout->setContentsMargins(MacLayoutLeftMargin, MacButtonTopMargin, MacLayoutRightMargin, MacLayoutBottomMargin);
pageVBoxLayout->setMargin(7);
pageVBoxLayout->setContentsMargins(7, 7, 7, 7);
} else {
if (modern) {
mainLayout->setMargin(0);
mainLayout->setContentsMargins(QMargins());
mainLayout->setSpacing(0);
pageVBoxLayout->setContentsMargins(deltaMarginLeft, deltaMarginTop,
deltaMarginRight, deltaMarginBottom);

View File

@ -3140,13 +3140,17 @@ QRect QCommonStyle::subElementRect(SubElement sr, const QStyleOption *opt,
///we need to access the widget here because the style option doesn't
//have all the information we need (ie. the layout's margin)
const QToolBar *tb = qobject_cast<const QToolBar*>(widget);
const int margin = tb && tb->layout() ? tb->layout()->margin() : 2;
const QMargins margins = tb && tb->layout() ? tb->layout()->contentsMargins() : QMargins(2, 2, 2, 2);
const int handleExtent = proxy()->pixelMetric(QStyle::PM_ToolBarHandleExtent, opt, tb);
if (tbopt->state & QStyle::State_Horizontal) {
r = QRect(margin, margin, handleExtent, tbopt->rect.height() - 2*margin);
r = QRect(margins.left(), margins.top(),
handleExtent,
tbopt->rect.height() - (margins.top() + margins.bottom()));
r = QStyle::visualRect(tbopt->direction, tbopt->rect, r);
} else {
r = QRect(margin, margin, tbopt->rect.width() - 2*margin, handleExtent);
r = QRect(margins.left(), margins.top(),
tbopt->rect.width() - (margins.left() + margins.right()),
handleExtent);
}
}
}

View File

@ -574,7 +574,7 @@ QBalloonTip::QBalloonTip(const QIcon &icon, const QString &title,
layout->addWidget(msgLabel, 1, 0, 1, 3);
#endif
layout->setSizeConstraint(QLayout::SetFixedSize);
layout->setMargin(3);
layout->setContentsMargins(3, 3, 3, 3);
setLayout(layout);
QPalette pal = palette();

View File

@ -185,7 +185,7 @@ QAbstractScrollAreaScrollBarContainer::QAbstractScrollAreaScrollBarContainer(Qt:
orientation(orientation)
{
setLayout(layout);
layout->setMargin(0);
layout->setContentsMargins(QMargins());
layout->setSpacing(0);
layout->addWidget(scrollBar);
layout->setSizeConstraint(QLayout::SetMaximumSize);

View File

@ -1778,7 +1778,7 @@ void QCalendarWidgetPrivate::createNavigationBar(QWidget *widget)
spaceHolder = new QSpacerItem(0,0);
QHBoxLayout *headerLayout = new QHBoxLayout;
headerLayout->setMargin(0);
headerLayout->setContentsMargins(QMargins());
headerLayout->setSpacing(0);
headerLayout->addWidget(prevMonth);
headerLayout->insertStretch(headerLayout->count());
@ -2101,7 +2101,7 @@ QCalendarWidget::QCalendarWidget(QWidget *parent)
setBackgroundRole(QPalette::Window);
QVBoxLayout *layoutV = new QVBoxLayout(this);
layoutV->setMargin(0);
layoutV->setContentsMargins(QMargins());
d->m_model = new QCalendarModel(this);
QTextCharFormat fmt;
fmt.setForeground(QBrush(Qt::red));
@ -2148,7 +2148,7 @@ QCalendarWidget::QCalendarWidget(QWidget *parent)
connect(d->yearEdit, SIGNAL(editingFinished()),
this, SLOT(_q_yearEditingFinished()));
layoutV->setMargin(0);
layoutV->setContentsMargins(QMargins());
layoutV->setSpacing(0);
layoutV->addWidget(d->navBarBackground);
layoutV->addWidget(d->m_view);

View File

@ -472,7 +472,7 @@ QComboBoxPrivateContainer::QComboBoxPrivateContainer(QAbstractItemView *itemView
// we need a vertical layout
QBoxLayout *layout = new QBoxLayout(QBoxLayout::TopToBottom, this);
layout->setSpacing(0);
layout->setMargin(0);
layout->setContentsMargins(QMargins());
// set item view
setItemView(itemView);

View File

@ -2598,7 +2598,7 @@ void QCalendarPopup::setCalendarWidget(QCalendarWidget *cw)
QVBoxLayout *widgetLayout = qobject_cast<QVBoxLayout*>(layout());
if (!widgetLayout) {
widgetLayout = new QVBoxLayout(this);
widgetLayout->setMargin(0);
widgetLayout->setContentsMargins(QMargins());
widgetLayout->setSpacing(0);
}
delete calendar.data();

View File

@ -2268,7 +2268,7 @@ QMdiSubWindow::QMdiSubWindow(QWidget *parent, Qt::WindowFlags flags)
setMouseTracking(true);
setLayout(new QVBoxLayout);
setFocusPolicy(Qt::StrongFocus);
layout()->setMargin(0);
layout()->setContentsMargins(QMargins());
d->updateGeometryConstraints();
setAttribute(Qt::WA_Resized, false);
d->titleBarPalette = d->desktopPalette();

View File

@ -482,14 +482,14 @@ void QStatusBar::reformat()
#if QT_CONFIG(sizegrip)
if (d->resizer) {
d->box = new QHBoxLayout(this);
d->box->setMargin(0);
d->box->setContentsMargins(QMargins());
vbox = new QVBoxLayout;
d->box->addLayout(vbox);
} else
#endif
{
vbox = d->box = new QVBoxLayout(this);
d->box->setMargin(0);
d->box->setContentsMargins(QMargins());
}
vbox->addSpacing(3);
QBoxLayout* l = new QHBoxLayout;

View File

@ -294,7 +294,7 @@ QToolBox::QToolBox(QWidget *parent, Qt::WindowFlags f)
{
Q_D(QToolBox);
d->layout = new QVBoxLayout(this);
d->layout->setMargin(0);
d->layout->setContentsMargins(QMargins());
setBackgroundRole(QPalette::Button);
}
@ -437,7 +437,7 @@ void QToolBoxPrivate::relayout()
Q_Q(QToolBox);
delete layout;
layout = new QVBoxLayout(q);
layout->setMargin(0);
layout->setContentsMargins(QMargins());
for (QToolBoxPrivate::PageList::ConstIterator i = pageList.constBegin(); i != pageList.constEnd(); ++i) {
layout->addWidget((*i).button);
layout->addWidget((*i).sv);