Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/QtWidgets/qformlayout.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 // Copyright (C) 2016 The Qt Company Ltd.
0002 // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
0003 
0004 #ifndef QFORMLAYOUT_H
0005 #define QFORMLAYOUT_H
0006 
0007 #include <QtWidgets/qtwidgetsglobal.h>
0008 #include <QtWidgets/QLayout>
0009 
0010 QT_REQUIRE_CONFIG(formlayout);
0011 
0012 QT_BEGIN_NAMESPACE
0013 
0014 
0015 class QFormLayoutPrivate;
0016 
0017 class Q_WIDGETS_EXPORT QFormLayout : public QLayout
0018 {
0019     Q_OBJECT
0020     Q_DECLARE_PRIVATE(QFormLayout)
0021     Q_PROPERTY(FieldGrowthPolicy fieldGrowthPolicy READ fieldGrowthPolicy WRITE setFieldGrowthPolicy
0022                RESET resetFieldGrowthPolicy)
0023     Q_PROPERTY(RowWrapPolicy rowWrapPolicy READ rowWrapPolicy WRITE setRowWrapPolicy
0024                RESET resetRowWrapPolicy)
0025     Q_PROPERTY(Qt::Alignment labelAlignment READ labelAlignment WRITE setLabelAlignment
0026                RESET resetLabelAlignment)
0027     Q_PROPERTY(Qt::Alignment formAlignment READ formAlignment WRITE setFormAlignment
0028                RESET resetFormAlignment)
0029     Q_PROPERTY(int horizontalSpacing READ horizontalSpacing WRITE setHorizontalSpacing)
0030     Q_PROPERTY(int verticalSpacing READ verticalSpacing WRITE setVerticalSpacing)
0031 
0032 public:
0033     enum FieldGrowthPolicy {
0034         FieldsStayAtSizeHint,
0035         ExpandingFieldsGrow,
0036         AllNonFixedFieldsGrow
0037     };
0038     Q_ENUM(FieldGrowthPolicy)
0039 
0040     enum RowWrapPolicy {
0041         DontWrapRows,
0042         WrapLongRows,
0043         WrapAllRows
0044     };
0045     Q_ENUM(RowWrapPolicy)
0046 
0047     enum ItemRole {
0048         LabelRole = 0,
0049         FieldRole = 1,
0050         SpanningRole = 2
0051     };
0052     Q_ENUM(ItemRole)
0053 
0054     struct TakeRowResult {
0055         QLayoutItem *labelItem;
0056         QLayoutItem *fieldItem;
0057     };
0058 
0059     explicit QFormLayout(QWidget *parent = nullptr);
0060     ~QFormLayout();
0061 
0062     void setFieldGrowthPolicy(FieldGrowthPolicy policy);
0063     FieldGrowthPolicy fieldGrowthPolicy() const;
0064     void setRowWrapPolicy(RowWrapPolicy policy);
0065     RowWrapPolicy rowWrapPolicy() const;
0066     void setLabelAlignment(Qt::Alignment alignment);
0067     Qt::Alignment labelAlignment() const;
0068     void setFormAlignment(Qt::Alignment alignment);
0069     Qt::Alignment formAlignment() const;
0070 
0071     void setHorizontalSpacing(int spacing);
0072     int horizontalSpacing() const;
0073     void setVerticalSpacing(int spacing);
0074     int verticalSpacing() const;
0075 
0076     int spacing() const override;
0077     void setSpacing(int) override;
0078 
0079     void addRow(QWidget *label, QWidget *field);
0080     void addRow(QWidget *label, QLayout *field);
0081     void addRow(const QString &labelText, QWidget *field);
0082     void addRow(const QString &labelText, QLayout *field);
0083     void addRow(QWidget *widget);
0084     void addRow(QLayout *layout);
0085 
0086     void insertRow(int row, QWidget *label, QWidget *field);
0087     void insertRow(int row, QWidget *label, QLayout *field);
0088     void insertRow(int row, const QString &labelText, QWidget *field);
0089     void insertRow(int row, const QString &labelText, QLayout *field);
0090     void insertRow(int row, QWidget *widget);
0091     void insertRow(int row, QLayout *layout);
0092 
0093     void removeRow(int row);
0094     void removeRow(QWidget *widget);
0095     void removeRow(QLayout *layout);
0096 
0097     TakeRowResult takeRow(int row);
0098     TakeRowResult takeRow(QWidget *widget);
0099     TakeRowResult takeRow(QLayout *layout);
0100 
0101     void setItem(int row, ItemRole role, QLayoutItem *item);
0102     void setWidget(int row, ItemRole role, QWidget *widget);
0103     void setLayout(int row, ItemRole role, QLayout *layout);
0104 
0105     void setRowVisible(int row, bool on);
0106     void setRowVisible(QWidget *widget, bool on);
0107     void setRowVisible(QLayout *layout, bool on);
0108 
0109     bool isRowVisible(int row) const;
0110     bool isRowVisible(QWidget *widget) const;
0111     bool isRowVisible(QLayout *layout) const;
0112 
0113     QLayoutItem *itemAt(int row, ItemRole role) const;
0114     void getItemPosition(int index, int *rowPtr, ItemRole *rolePtr) const;
0115     void getWidgetPosition(QWidget *widget, int *rowPtr, ItemRole *rolePtr) const;
0116     void getLayoutPosition(QLayout *layout, int *rowPtr, ItemRole *rolePtr) const;
0117     QWidget *labelForField(QWidget *field) const;
0118     QWidget *labelForField(QLayout *field) const;
0119 
0120     // reimplemented from QLayout
0121     void addItem(QLayoutItem *item) override;
0122     QLayoutItem *itemAt(int index) const override;
0123     QLayoutItem *takeAt(int index) override;
0124 
0125     void setGeometry(const QRect &rect) override;
0126     QSize minimumSize() const override;
0127     QSize sizeHint() const override;
0128     void invalidate() override;
0129 
0130     bool hasHeightForWidth() const override;
0131     int heightForWidth(int width) const override;
0132     Qt::Orientations expandingDirections() const override;
0133     int count() const override;
0134 
0135     int rowCount() const;
0136 
0137 #if 0
0138     void dump() const;
0139 #endif
0140 
0141 private:
0142     void resetFieldGrowthPolicy();
0143     void resetRowWrapPolicy();
0144     void resetLabelAlignment();
0145     void resetFormAlignment();
0146 };
0147 
0148 Q_DECLARE_TYPEINFO(QFormLayout::TakeRowResult, Q_PRIMITIVE_TYPE);
0149 
0150 QT_END_NAMESPACE
0151 
0152 #endif