44 lines
1.1 KiB
C++
44 lines
1.1 KiB
C++
#ifndef FLOWLAYOUT_H
|
|
#define FLOWLAYOUT_H
|
|
|
|
#include <QLayout>
|
|
#include <QList>
|
|
#include <QRect>
|
|
#include <QStyle>
|
|
|
|
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<QLayoutItem *> m_items;
|
|
int m_hSpacing;
|
|
int m_vSpacing;
|
|
};
|
|
|
|
#endif // FLOWLAYOUT_H
|