more updates
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
|
||||
#include "flowlayout.h"
|
||||
//! [1]
|
||||
FlowLayout::FlowLayout(QWidget *parent, int margin, int hSpacing, int vSpacing)
|
||||
FlowLayout::FlowLayout(QWidget* parent, int margin, int hSpacing, int vSpacing)
|
||||
: QLayout(parent), m_hSpace(hSpacing), m_vSpace(vSpacing)
|
||||
{
|
||||
setContentsMargins(margin, margin, margin, margin);
|
||||
@@ -102,6 +102,8 @@ QSize FlowLayout::minimumSize() const
|
||||
|
||||
const QMargins margins = contentsMargins();
|
||||
size += QSize(margins.left() + margins.right(), margins.top() + margins.bottom());
|
||||
if (size.height() < minimumHeight())
|
||||
size.rheight() = minimumHeight();
|
||||
return size;
|
||||
}
|
||||
|
||||
@@ -143,12 +145,41 @@ int FlowLayout::doLayout(const QRect &rect, bool testOnly) const
|
||||
int FlowLayout::smartSpacing(QStyle::PixelMetric pm) const
|
||||
{
|
||||
QObject* parent = this->parent();
|
||||
if (!parent) {
|
||||
if (!parent)
|
||||
{
|
||||
return -1;
|
||||
} else if (parent->isWidgetType()) {
|
||||
QWidget* pw = static_cast<QWidget *>(parent);
|
||||
}
|
||||
else if (parent->isWidgetType())
|
||||
{
|
||||
QWidget* pw = static_cast<QWidget*>(parent);
|
||||
return pw->style()->pixelMetric(pm, nullptr, pw);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
return static_cast<QLayout*>(parent)->spacing();
|
||||
}
|
||||
}
|
||||
|
||||
void FlowLayout::setIndex(QWidget* wid, int index)
|
||||
{
|
||||
if (itemAt(index)->widget() == wid)
|
||||
return;
|
||||
wid->setParent(nullptr);
|
||||
addWidget(wid);
|
||||
if (index < 0)
|
||||
return;
|
||||
for (int i = count()-1; i > index; i--)
|
||||
{
|
||||
itemList.swapItemsAt(i-1, i);
|
||||
}
|
||||
}
|
||||
|
||||
void FlowLayout::setMinimumHeight(int minh)
|
||||
{
|
||||
_minimumHeight = minh;
|
||||
}
|
||||
|
||||
int FlowLayout::minimumHeight() const
|
||||
{
|
||||
return _minimumHeight;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user