#ifndef FLOWLAYOUT_H #define FLOWLAYOUT_H #include #include #include #include class FlowLayout : public QLayout { public: explicit FlowLayout(QWidget *parent = nullptr, int margin = 0, int hSpacing = -1, int vSpacing = -1); ~FlowLayout() override; void clear(); void addItem(QLayoutItem *item) override; int count() const override; QLayoutItem *itemAt(int index) const override; QLayoutItem *takeAt(int index) override; Qt::Orientations expandingDirections() const override; bool hasHeightForWidth() const override; int heightForWidth(int width) const override; void setGeometry(const QRect &rect) override; QSize sizeHint() const override; QSize minimumSize() const override; private: int doLayout(const QRect &rect, bool testOnly) const; int horizontalSpacing() const; int verticalSpacing() const; int smartSpacing(QStyle::PixelMetric pm) const; QList m_items; int m_hSpacing; int m_vSpacing; }; #endif // FLOWLAYOUT_H