QAbstractScrollArea: add a getter for the margins
Strange API asymmetry that needed to be fixed. Task-number: QTBUG-8315 [ChangeLog][QtWidgets][QAbstractScrollArea] A getter for the viewport margins has been added. Change-Id: Ie1460b572206922031fc4effc2aa8261e25088b5 Reviewed-by: Joerg Bornemann <joerg.bornemann@theqtcompany.com>
This commit is contained in:
parent
5180f32c5a
commit
d41834b953
@ -923,7 +923,7 @@ QWidgetList QAbstractScrollArea::scrollBarWidgets(Qt::Alignment alignment)
|
||||
they should not call this function.
|
||||
|
||||
By default all margins are zero.
|
||||
|
||||
\sa viewportMargins()
|
||||
*/
|
||||
void QAbstractScrollArea::setViewportMargins(int left, int top, int right, int bottom)
|
||||
{
|
||||
@ -943,7 +943,7 @@ void QAbstractScrollArea::setViewportMargins(int left, int top, int right, int b
|
||||
area.
|
||||
|
||||
By default all margins are zero.
|
||||
|
||||
\sa viewportMargins()
|
||||
*/
|
||||
void QAbstractScrollArea::setViewportMargins(const QMargins &margins)
|
||||
{
|
||||
@ -951,6 +951,19 @@ void QAbstractScrollArea::setViewportMargins(const QMargins &margins)
|
||||
margins.right(), margins.bottom());
|
||||
}
|
||||
|
||||
/*!
|
||||
\since 5.5
|
||||
Returns the margins around the scrolling area.
|
||||
By default all the margins are zero.
|
||||
|
||||
\sa setViewportMargins()
|
||||
*/
|
||||
QMargins QAbstractScrollArea::viewportMargins() const
|
||||
{
|
||||
Q_D(const QAbstractScrollArea);
|
||||
return QMargins(d->left, d->top, d->right, d->bottom);
|
||||
}
|
||||
|
||||
/*! \internal */
|
||||
bool QAbstractScrollArea::eventFilter(QObject *o, QEvent *e)
|
||||
{
|
||||
|
@ -97,6 +97,7 @@ protected:
|
||||
QAbstractScrollArea(QAbstractScrollAreaPrivate &dd, QWidget *parent = 0);
|
||||
void setViewportMargins(int left, int top, int right, int bottom);
|
||||
void setViewportMargins(const QMargins &margins);
|
||||
QMargins viewportMargins() const;
|
||||
|
||||
bool eventFilter(QObject *, QEvent *) Q_DECL_OVERRIDE;
|
||||
bool event(QEvent *) Q_DECL_OVERRIDE;
|
||||
|
@ -60,6 +60,8 @@ private slots:
|
||||
void viewportCrash();
|
||||
void task214488_layoutDirection_data();
|
||||
void task214488_layoutDirection();
|
||||
|
||||
void margins();
|
||||
};
|
||||
|
||||
tst_QAbstractScrollArea::tst_QAbstractScrollArea()
|
||||
@ -375,5 +377,22 @@ void tst_QAbstractScrollArea::patternBackground()
|
||||
QCOMPARE(image.pixel(QPoint(20,20)) , QColor(Qt::red).rgb());
|
||||
}
|
||||
|
||||
class ScrollArea : public QAbstractScrollArea
|
||||
{
|
||||
public:
|
||||
using QAbstractScrollArea::setViewportMargins;
|
||||
using QAbstractScrollArea::viewportMargins;
|
||||
};
|
||||
|
||||
void tst_QAbstractScrollArea::margins()
|
||||
{
|
||||
ScrollArea area;
|
||||
QCOMPARE(area.viewportMargins(), QMargins());
|
||||
|
||||
QMargins margins(10, 20, 30, 40);
|
||||
area.setViewportMargins(margins);
|
||||
QCOMPARE(area.viewportMargins(), margins);
|
||||
}
|
||||
|
||||
QTEST_MAIN(tst_QAbstractScrollArea)
|
||||
#include "tst_qabstractscrollarea.moc"
|
||||
|
Loading…
x
Reference in New Issue
Block a user