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>
This commit is contained in:
parent
76be819345
commit
130fd22d39
@ -779,8 +779,7 @@ int QAccessibleLineEdit::cursorPosition() const
|
||||
QRect QAccessibleLineEdit::characterRect(int offset) const
|
||||
{
|
||||
int x = lineEdit()->d_func()->control->cursorToX(offset);
|
||||
int y;
|
||||
lineEdit()->getTextMargins(0, &y, 0, 0);
|
||||
int y = lineEdit()->textMargins().top();
|
||||
QFontMetrics fm(lineEdit()->font());
|
||||
const QString ch = text(offset, offset + 1);
|
||||
if (ch.isEmpty())
|
||||
|
@ -697,9 +697,7 @@ void QGraphicsProxyWidgetPrivate::setWidget_helper(QWidget *newWidget, bool auto
|
||||
if (!newWidget->testAttribute(Qt::WA_Resized))
|
||||
newWidget->adjustSize();
|
||||
|
||||
int left, top, right, bottom;
|
||||
newWidget->getContentsMargins(&left, &top, &right, &bottom);
|
||||
q->setContentsMargins(left, top, right, bottom);
|
||||
q->setContentsMargins(newWidget->contentsMargins());
|
||||
q->setWindowTitle(newWidget->windowTitle());
|
||||
|
||||
// size policies and constraints..
|
||||
|
@ -570,11 +570,9 @@ void QExpandingLineEdit::changeEvent(QEvent *e)
|
||||
|
||||
void QExpandingLineEdit::updateMinimumWidth()
|
||||
{
|
||||
int left, right;
|
||||
getTextMargins(&left, 0, &right, 0);
|
||||
int width = left + right + 4 /*horizontalMargin in qlineedit.cpp*/;
|
||||
getContentsMargins(&left, 0, &right, 0);
|
||||
width += left + right;
|
||||
const QMargins tm = textMargins();
|
||||
const QMargins cm = contentsMargins();
|
||||
const int width = tm.left() + tm.right() + cm.left() + cm.right() + 4 /*horizontalMargin in qlineedit.cpp*/;
|
||||
|
||||
QStyleOptionFrame opt;
|
||||
initStyleOption(&opt);
|
||||
|
@ -7634,7 +7634,7 @@ bool QWidget::restoreGeometry(const QByteArray &geometry)
|
||||
|
||||
Changing the margins will trigger a resizeEvent().
|
||||
|
||||
\sa contentsRect(), getContentsMargins()
|
||||
\sa contentsRect(), contentsMargins()
|
||||
*/
|
||||
void QWidget::setContentsMargins(int left, int top, int right, int bottom)
|
||||
{
|
||||
@ -7664,7 +7664,7 @@ void QWidget::setContentsMargins(int left, int top, int right, int bottom)
|
||||
|
||||
Changing the margins will trigger a resizeEvent().
|
||||
|
||||
\sa contentsRect(), getContentsMargins()
|
||||
\sa contentsRect(), contentsMargins()
|
||||
*/
|
||||
void QWidget::setContentsMargins(const QMargins &margins)
|
||||
{
|
||||
@ -7693,7 +7693,11 @@ void QWidgetPrivate::updateContentsRect()
|
||||
QCoreApplication::sendEvent(q, &e);
|
||||
}
|
||||
|
||||
#if QT_DEPRECATED_SINCE(5, 14)
|
||||
/*!
|
||||
\obsolete
|
||||
Use contentsMargins().
|
||||
|
||||
Returns the widget's contents margins for \a left, \a top, \a
|
||||
right, and \a bottom.
|
||||
|
||||
@ -7711,6 +7715,7 @@ void QWidget::getContentsMargins(int *left, int *top, int *right, int *bottom) c
|
||||
if (bottom)
|
||||
*bottom = m.bottom();
|
||||
}
|
||||
#endif
|
||||
|
||||
// FIXME: Move to qmargins.h for next minor Qt release
|
||||
QMargins operator|(const QMargins &m1, const QMargins &m2)
|
||||
@ -7724,7 +7729,7 @@ QMargins operator|(const QMargins &m1, const QMargins &m2)
|
||||
|
||||
\brief The contentsMargins function returns the widget's contents margins.
|
||||
|
||||
\sa getContentsMargins(), setContentsMargins(), contentsRect()
|
||||
\sa setContentsMargins(), contentsRect()
|
||||
*/
|
||||
QMargins QWidget::contentsMargins() const
|
||||
{
|
||||
@ -7737,7 +7742,7 @@ QMargins QWidget::contentsMargins() const
|
||||
/*!
|
||||
Returns the area inside the widget's margins.
|
||||
|
||||
\sa setContentsMargins(), getContentsMargins()
|
||||
\sa setContentsMargins(), contentsMargins()
|
||||
*/
|
||||
QRect QWidget::contentsRect() const
|
||||
{
|
||||
|
@ -524,7 +524,10 @@ public:
|
||||
|
||||
void setContentsMargins(int left, int top, int right, int bottom);
|
||||
void setContentsMargins(const QMargins &margins);
|
||||
#if QT_DEPRECATED_SINCE(5, 14)
|
||||
QT_DEPRECATED_X("use contentsMargins()")
|
||||
void getContentsMargins(int *left, int *top, int *right, int *bottom) const;
|
||||
#endif
|
||||
QMargins contentsMargins() const;
|
||||
|
||||
QRect contentsRect() const;
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
@ -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*)));
|
||||
|
@ -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user