| 1 |
// Copyright (C) 2016 The Qt Company Ltd. |
| 2 |
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause |
| 3 |
|
| 4 |
#ifndef FLOWLAYOUT_H |
| 5 |
#define FLOWLAYOUT_H |
| 6 |
|
| 7 |
#include <QLayout> |
| 8 |
#include <QRect> |
| 9 |
#include <QStyle> |
| 10 |
//! [0] |
| 11 |
class FlowLayout : public QLayout |
| 12 |
{ |
| 13 |
public: |
| 14 |
explicit FlowLayout(QWidget *parent, int margin = -1, int hSpacing = -1, int vSpacing = -1); |
| 15 |
explicit FlowLayout(int margin = -1, int hSpacing = -1, int vSpacing = -1); |
| 16 |
~FlowLayout(); |
| 17 |
|
| 18 |
void addItem(QLayoutItem *item) override; |
| 19 |
int horizontalSpacing() const; |
| 20 |
int verticalSpacing() const; |
| 21 |
Qt::Orientations expandingDirections() const override; |
| 22 |
bool hasHeightForWidth() const override; |
| 23 |
int heightForWidth(int) const override; |
| 24 |
int count() const override; |
| 25 |
QLayoutItem *itemAt(int index) const override; |
| 26 |
QSize minimumSize() const override; |
| 27 |
void setGeometry(const QRect &rect) override; |
| 28 |
QSize sizeHint() const override; |
| 29 |
QLayoutItem *takeAt(int index) override; |
| 30 |
|
| 31 |
private: |
| 32 |
int doLayout(const QRect &rect, bool testOnly) const; |
| 33 |
int smartSpacing(QStyle::PixelMetric pm) const; |
| 34 |
|
| 35 |
QList<QLayoutItem *> itemList; |
| 36 |
int m_hSpace; |
| 37 |
int m_vSpace; |
| 38 |
}; |
| 39 |
//! [0] |
| 40 |
|
| 41 |
#endif // FLOWLAYOUT_H |