]> sigrok.org Git - pulseview.git/blobdiff - pv/widgets/flowlayout.cpp
Session: Fix issue #67 by improving error handling
[pulseview.git] / pv / widgets / flowlayout.cpp
index 31ba7fed425e53b74774363480499f85313e06ed..73916700253087617a0539a44e6caa6579043840 100644 (file)
@@ -102,7 +102,7 @@ QLayoutItem *FlowLayout::takeAt(int index)
        if ((index >= 0) && (index < itemList.size()))
                return itemList.takeAt(index);
        else
-               return 0;
+               return nullptr;
 }
 
 Qt::Orientations FlowLayout::expandingDirections() const
@@ -141,12 +141,18 @@ QSize FlowLayout::minimumSize() const
                if (w > size.width())
                        size.setWidth(w);
 
-               int h = item->geometry().y() + item->geometry().width();
+               int h = item->geometry().y() + item->geometry().height();
                if (h > size.height())
                        size.setHeight(h);
        }
 
+#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
+       int left, top, right, bottom;
+       getContentsMargins(&left, &top, &right, &bottom);
+       size += QSize(left + right, top + bottom);
+#else
        size += QSize(2 * margin(), 2 * margin());
+#endif
 
        return size;
 }
@@ -206,7 +212,7 @@ int FlowLayout::smartSpacing(QStyle::PixelMetric pm) const
 
        if (parent->isWidgetType()) {
                QWidget *pw = qobject_cast<QWidget*>(parent);
-               return pw->style()->pixelMetric(pm, 0, pw);
+               return pw->style()->pixelMetric(pm, nullptr, pw);
        } else
                return static_cast<QLayout*>(parent)->spacing();
 }