Fix possible nullptr exception in FlowLayout
MODIFY
src/flowlayout.cpp
src/flowlayout.cpp
@@ -177,15 +177,15 @@ int FlowLayout::doLayout(const QRect &rect, bool testOnly) const
//! [10]
for (QLayoutItem *item : qAsConst(itemList)) {
- const QWidget *wid = item->widget();
int spaceX = horizontalSpacing();
+ int spaceY = verticalSpacing();
if (spaceX == -1)
- spaceX = wid->style()->layoutSpacing(
+ spaceX = QApplication::style()->layoutSpacing(
QSizePolicy::PushButton, QSizePolicy::PushButton, Qt::Horizontal);
- int spaceY = verticalSpacing();
if (spaceY == -1)
- spaceY = wid->style()->layoutSpacing(
+ spaceY = QApplication::style()->layoutSpacing(
QSizePolicy::PushButton, QSizePolicy::PushButton, Qt::Vertical);
+
//! [10]
//! [11]
int nextX = x + item->sizeHint().width() + spaceX;

Fix possible nullptr exception in FlowLayout