summaryrefslogtreecommitdiffstats
path: root/src/widgets/widgets
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2019-05-24 19:51:38 +0200
committerMarc Mutz <marc.mutz@kdab.com>2019-07-30 22:41:19 +0300
commit130fd22d399624c863bbaad2f72d2213a48e9e13 (patch)
treeb8ae7745316d031ae79c6d7ddf6910fd59643a78 /src/widgets/widgets
parent76be819345228d589cbc4f5129617151ea604750 (diff)
QWidget/QLineEdit: deprecate get{Contents,Text}Margins()
We have contentsMargins() and textMargins() methods since 4.6 which are much more efficient and easier to use. [ChangeLog][QtWidgets][QLineEdit] The getTextMargins() member function has been deprecated in favor of textMargins(). [ChangeLog][QtWidgets][QWidget] The getContentsMargins() member function has been deprecated in favor of contentsMargins(). Change-Id: Ifdb890af6198fc682b94701786c67a5b945a4b4c Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/widgets/widgets')
-rw-r--r--src/widgets/widgets/qcombobox.cpp13
-rw-r--r--src/widgets/widgets/qlineedit.cpp7
-rw-r--r--src/widgets/widgets/qlineedit.h3
-rw-r--r--src/widgets/widgets/qmenu.cpp4
-rw-r--r--src/widgets/widgets/qsplitter.cpp7
5 files changed, 19 insertions, 15 deletions
diff --git a/src/widgets/widgets/qcombobox.cpp b/src/widgets/widgets/qcombobox.cpp
index 5c368db83a..8b54d61e8e 100644
--- a/src/widgets/widgets/qcombobox.cpp
+++ b/src/widgets/widgets/qcombobox.cpp
@@ -2714,15 +2714,14 @@ void QComboBox::showPopup()
int heightMargin = container->topMargin() + container->bottomMargin();
// add the frame of the container
- int marginTop, marginBottom;
- container->getContentsMargins(0, &marginTop, 0, &marginBottom);
- heightMargin += marginTop + marginBottom;
+ const QMargins cm = container->contentsMargins();
+ heightMargin += cm.top() + cm.bottom();
//add the frame of the view
- view()->getContentsMargins(0, &marginTop, 0, &marginBottom);
- marginTop += static_cast<QAbstractScrollAreaPrivate *>(QObjectPrivate::get(view()))->top;
- marginBottom += static_cast<QAbstractScrollAreaPrivate *>(QObjectPrivate::get(view()))->bottom;
- heightMargin += marginTop + marginBottom;
+ const QMargins vm = view()->contentsMargins();
+ heightMargin += vm.top() + vm.bottom();
+ heightMargin += static_cast<QAbstractScrollAreaPrivate *>(QObjectPrivate::get(view()))->top;
+ heightMargin += static_cast<QAbstractScrollAreaPrivate *>(QObjectPrivate::get(view()))->bottom;
listRect.setHeight(listRect.height() + heightMargin);
}
diff --git a/src/widgets/widgets/qlineedit.cpp b/src/widgets/widgets/qlineedit.cpp
index 28d18872ce..7f482a6a4e 100644
--- a/src/widgets/widgets/qlineedit.cpp
+++ b/src/widgets/widgets/qlineedit.cpp
@@ -1129,7 +1129,7 @@ bool QLineEdit::hasAcceptableInput() const
sizes \a left, \a top, \a right, and \a bottom.
\since 4.5
- See also getTextMargins().
+ See also textMargins().
*/
void QLineEdit::setTextMargins(int left, int top, int right, int bottom)
{
@@ -1150,7 +1150,11 @@ void QLineEdit::setTextMargins(const QMargins &margins)
update();
}
+#if QT_DEPRECATED_SINCE(5, 14)
/*!
+ \obsolete
+ Use textMargins()
+
Returns the widget's text margins for \a left, \a top, \a right, and \a bottom.
\since 4.5
@@ -1168,6 +1172,7 @@ void QLineEdit::getTextMargins(int *left, int *top, int *right, int *bottom) con
if (bottom)
*bottom = m.bottom();
}
+#endif
/*!
\since 4.6
diff --git a/src/widgets/widgets/qlineedit.h b/src/widgets/widgets/qlineedit.h
index de82927f74..1cf1f24449 100644
--- a/src/widgets/widgets/qlineedit.h
+++ b/src/widgets/widgets/qlineedit.h
@@ -172,7 +172,10 @@ public:
void setTextMargins(int left, int top, int right, int bottom);
void setTextMargins(const QMargins &margins);
+#if QT_DEPRECATED_SINCE(5, 14)
+ QT_DEPRECATED_X("use textMargins()")
void getTextMargins(int *left, int *top, int *right, int *bottom) const;
+#endif
QMargins textMargins() const;
#if QT_CONFIG(action)
diff --git a/src/widgets/widgets/qmenu.cpp b/src/widgets/widgets/qmenu.cpp
index 310c865f52..e38490dabd 100644
--- a/src/widgets/widgets/qmenu.cpp
+++ b/src/widgets/widgets/qmenu.cpp
@@ -142,9 +142,7 @@ public:
#endif
if (style() != p->style())
setStyle(p->style());
- int leftMargin, topMargin, rightMargin, bottomMargin;
- p->getContentsMargins(&leftMargin, &topMargin, &rightMargin, &bottomMargin);
- setContentsMargins(leftMargin, topMargin, rightMargin, bottomMargin);
+ setContentsMargins(p->contentsMargins());
setLayoutDirection(p->layoutDirection());
//QObject::connect(this, SIGNAL(triggered(QAction*)), this, SLOT(onTrigger(QAction*)));
//QObject::connect(this, SIGNAL(hovered(QAction*)), this, SLOT(onHovered(QAction*)));
diff --git a/src/widgets/widgets/qsplitter.cpp b/src/widgets/widgets/qsplitter.cpp
index 08533040a7..e7a4889996 100644
--- a/src/widgets/widgets/qsplitter.cpp
+++ b/src/widgets/widgets/qsplitter.cpp
@@ -771,14 +771,13 @@ void QSplitterPrivate::setGeo(QSplitterLayoutStruct *sls, int p, int s, bool all
if (!sls->handle->isHidden()) {
QSplitterHandle *h = sls->handle;
QSize hs = h->sizeHint();
- int left, top, right, bottom;
- h->getContentsMargins(&left, &top, &right, &bottom);
+ const QMargins m = h->contentsMargins();
if (orient==Qt::Horizontal) {
if (q->isRightToLeft())
p = contents.width() - p + hs.width();
- h->setGeometry(p-hs.width() - left, contents.y(), hs.width() + left + right, contents.height());
+ h->setGeometry(p-hs.width() - m.left(), contents.y(), hs.width() + m.left() + m.right(), contents.height());
} else {
- h->setGeometry(contents.x(), p-hs.height() - top, contents.width(), hs.height() + top + bottom);
+ h->setGeometry(contents.x(), p-hs.height() - m.top(), contents.width(), hs.height() + m.top() + m.bottom());
}
}
}