summaryrefslogtreecommitdiffstats
path: root/src/widgets/kernel/qlayout.cpp
diff options
context:
space:
mode:
authorVolker Hilsheimer <volker.hilsheimer@qt.io>2020-06-08 18:28:52 +0200
committerVolker Hilsheimer <volker.hilsheimer@qt.io>2020-06-09 16:31:54 +0200
commitfd856532d7472ccc6daf6a95d5c28264d9e6adca (patch)
treea0b1fb8b99a76b5a691131f55d4d7a80790073b1 /src/widgets/kernel/qlayout.cpp
parent385f0732d927f0eba8ecf990ee9bc19936475edd (diff)
Make QLayout::spacing/setSpacing virtual, remove qobject_cast hack
Change-Id: If256609a1f561b957378010d88120f5aaf94a45e Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
Diffstat (limited to 'src/widgets/kernel/qlayout.cpp')
-rw-r--r--src/widgets/kernel/qlayout.cpp39
1 files changed, 8 insertions, 31 deletions
diff --git a/src/widgets/kernel/qlayout.cpp b/src/widgets/kernel/qlayout.cpp
index 901e136f61..300dded3a4 100644
--- a/src/widgets/kernel/qlayout.cpp
+++ b/src/widgets/kernel/qlayout.cpp
@@ -55,9 +55,6 @@
#include "qvariant.h"
#include "qwidget_p.h"
#include "qlayout_p.h"
-#if QT_CONFIG(formlayout)
-#include "qformlayout.h"
-#endif
QT_BEGIN_NAMESPACE
@@ -301,40 +298,20 @@ bool QLayout::setAlignment(QLayout *l, Qt::Alignment alignment)
int QLayout::spacing() const
{
- if (const QBoxLayout* boxlayout = qobject_cast<const QBoxLayout*>(this)) {
- return boxlayout->spacing();
- } else if (const QGridLayout* gridlayout = qobject_cast<const QGridLayout*>(this)) {
- return gridlayout->spacing();
-#if QT_CONFIG(formlayout)
- } else if (const QFormLayout* formlayout = qobject_cast<const QFormLayout*>(this)) {
- return formlayout->spacing();
-#endif
+ Q_D(const QLayout);
+ if (d->insideSpacing >=0) {
+ return d->insideSpacing;
} else {
- Q_D(const QLayout);
- if (d->insideSpacing >=0) {
- return d->insideSpacing;
- } else {
- // arbitrarily prefer horizontal spacing to vertical spacing
- return qSmartSpacing(this, QStyle::PM_LayoutHorizontalSpacing);
- }
+ // arbitrarily prefer horizontal spacing to vertical spacing
+ return qSmartSpacing(this, QStyle::PM_LayoutHorizontalSpacing);
}
}
void QLayout::setSpacing(int spacing)
{
- if (QBoxLayout* boxlayout = qobject_cast<QBoxLayout*>(this)) {
- boxlayout->setSpacing(spacing);
- } else if (QGridLayout* gridlayout = qobject_cast<QGridLayout*>(this)) {
- gridlayout->setSpacing(spacing);
-#if QT_CONFIG(formlayout)
- } else if (QFormLayout* formlayout = qobject_cast<QFormLayout*>(this)) {
- formlayout->setSpacing(spacing);
-#endif
- } else {
- Q_D(QLayout);
- d->insideSpacing = spacing;
- invalidate();
- }
+ Q_D(QLayout);
+ d->insideSpacing = spacing;
+ invalidate();
}
/*!