Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qlayout.h
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3// Qt-Security score:significant reason:default
4
5#ifndef QLAYOUT_H
6#define QLAYOUT_H
7
8#include <QtWidgets/qtwidgetsglobal.h>
9#include <QtCore/qobject.h>
10#include <QtWidgets/qlayoutitem.h>
11#include <QtWidgets/qsizepolicy.h>
12#include <QtCore/qrect.h>
13#include <QtCore/qmargins.h>
14
15#include <limits.h>
16
17QT_BEGIN_NAMESPACE
18
19
20class QLayout;
21class QSize;
22
23
24class QLayoutPrivate;
25
26class Q_WIDGETS_EXPORT QLayout : public QObject, public QLayoutItem
27{
28 Q_OBJECT
29 Q_DECLARE_PRIVATE(QLayout)
30
31 Q_PROPERTY(int spacing READ spacing WRITE setSpacing)
32 Q_PROPERTY(QMargins contentsMargins READ contentsMargins WRITE setContentsMargins
33 RESET unsetContentsMargins)
34
35 Q_PROPERTY(SizeConstraint sizeConstraint READ sizeConstraint WRITE setSizeConstraint)
36 Q_PROPERTY(SizeConstraint horizontalSizeConstraint READ horizontalSizeConstraint WRITE setHorizontalSizeConstraint)
37 Q_PROPERTY(SizeConstraint verticalSizeConstraint READ verticalSizeConstraint WRITE setVerticalSizeConstraint)
38
39public:
40 enum SizeConstraint {
41 SetDefaultConstraint,
42 SetNoConstraint,
43 SetMinimumSize,
44 SetFixedSize,
45 SetMaximumSize,
46 SetMinAndMaxSize
47 };
48 Q_ENUM(SizeConstraint)
49
50 explicit QLayout(QWidget *parent = nullptr);
51 ~QLayout();
52
53 virtual int spacing() const;
54 virtual void setSpacing(int);
55
56 void setContentsMargins(int left, int top, int right, int bottom);
57 void setContentsMargins(const QMargins &margins);
58 void unsetContentsMargins();
59 void getContentsMargins(int *left, int *top, int *right, int *bottom) const;
60 QMargins contentsMargins() const;
61 QRect contentsRect() const;
62
63 bool setAlignment(QWidget *w, Qt::Alignment alignment);
64 bool setAlignment(QLayout *l, Qt::Alignment alignment);
65 using QLayoutItem::setAlignment;
66
67 void setSizeConstraint(SizeConstraint constraint);
68 SizeConstraint sizeConstraint() const;
69
70 void setSizeConstraints(SizeConstraint horizontal, SizeConstraint vertical);
71
72 void setHorizontalSizeConstraint(SizeConstraint constraint);
73 SizeConstraint horizontalSizeConstraint() const;
74
75 void setVerticalSizeConstraint(SizeConstraint constraint);
76 SizeConstraint verticalSizeConstraint() const;
77
78 void setMenuBar(QWidget *w);
79 QWidget *menuBar() const;
80
81 QWidget *parentWidget() const;
82
83 void invalidate() override;
84 QRect geometry() const override;
85 bool activate();
86 void update();
87
88 void addWidget(QWidget *w);
89 virtual void addItem(QLayoutItem *) = 0;
90
91 void removeWidget(QWidget *w);
92 void removeItem(QLayoutItem *);
93
94 Qt::Orientations expandingDirections() const override;
95 QSize minimumSize() const override;
96 QSize maximumSize() const override;
97 virtual void setGeometry(const QRect&) override;
98 virtual QLayoutItem *itemAt(int index) const = 0;
99 virtual QLayoutItem *takeAt(int index) = 0;
100 virtual int indexOf(const QWidget *) const;
101 virtual int indexOf(const QLayoutItem *) const;
102 virtual int count() const = 0;
103 bool isEmpty() const override;
104 QSizePolicy::ControlTypes controlTypes() const override;
105
106 virtual QLayoutItem *replaceWidget(QWidget *from, QWidget *to,
107 Qt::FindChildOptions options = Qt::FindChildrenRecursively);
108
109 int totalMinimumHeightForWidth(int w) const;
110 int totalHeightForWidth(int w) const;
111 QSize totalMinimumSize() const;
112 QSize totalMaximumSize() const;
113 QSize totalSizeHint() const;
114 QLayout *layout() override;
115
116 void setEnabled(bool);
117 bool isEnabled() const;
118
119
120 static QSize closestAcceptableSize(const QWidget *w, const QSize &s);
121
122protected:
123 void widgetEvent(QEvent *);
124 void childEvent(QChildEvent *e) override;
125 void addChildLayout(QLayout *l);
126 void addChildWidget(QWidget *w);
127 bool adoptLayout(QLayout *layout);
128
129 QRect alignmentRect(const QRect&) const;
130protected:
131 QLayout(QLayoutPrivate &d, QLayout*, QWidget*);
132
133private:
134 Q_DISABLE_COPY(QLayout)
135
136 static void activateRecursiveHelper(QLayoutItem *item);
137
138 friend class QApplicationPrivate;
139 friend class QWidget;
140
141};
142
143QT_END_NAMESPACE
144
145//### support old includes
146#include <QtWidgets/qboxlayout.h>
147#include <QtWidgets/qgridlayout.h>
148
149#endif // QLAYOUT_H
QColor grabScreenColor(const QPoint &p)
bool selectColor(const QColor &color)
void init(const QColor &initial)
void setCurrentAlpha(int a)
QColorPickingEventFilter * colorPickingEventFilter
bool handleColorPickingMouseButtonRelease(QMouseEvent *e)
QColor currentQColor() const
bool handleColorPickingMouseMove(QMouseEvent *e)
void _q_setCustom(int index, QRgb color)
QPushButton * eyeDropperButton
void updateColorLabelText(const QPoint &)
void setCurrentColor(const QColor &color, SetColorMode setColorMode=SetColorAll)
bool isAlphaVisible() const
QVBoxLayout * leftLay
void setCurrentQColor(const QColor &color)
bool canBeNativeDialog() const override
void setCurrentRgbColor(QRgb rgb)
QRgb currentColor() const
void newColorTypedIn(QRgb rgb)
bool handleColorPickingKeyPress(QKeyEvent *e)
void updateColorPicking(const QPoint &pos)
QSharedPointer< QColorDialogOptions > options
void newStandard(int, int)
void setVisible(bool visible) override
QDialogButtonBox * buttons
bool supportsColorPicking() const
QPointer< QObject > receiverToDisconnectOnClose
virtual void initHelper(QPlatformDialogHelper *h) override
QByteArray memberToDisconnectOnClose
QPushButton * addCusBt
void newHsv(int h, int s, int v)
virtual void helperPrepareShow(QPlatformDialogHelper *h) override
QColorLuminancePicker * lp
void newCustom(int, int)
QPlatformColorDialogHelper * platformColorDialogHelper() const
void nextCustom(int, int)
The QColorDialog class provides a dialog widget for specifying colors.
friend class QPainter
\inmodule QtCore\reentrant
Definition qpoint.h:29
QColSpinBox(QWidget *parent)
void paintEvent(QPaintEvent *) override
This event handler can be reimplemented in a subclass to receive paint events passed in event.
void keyPressEvent(QKeyEvent *event) override
This event handler, for event event, can be reimplemented in a subclass to receive key press events f...
void mouseMoveEvent(QMouseEvent *) override
This event handler, for event event, can be reimplemented in a subclass to receive mouse move events ...
void mousePressEvent(QMouseEvent *) override
This event handler, for event event, can be reimplemented in a subclass to receive mouse press events...
void paintEvent(QPaintEvent *) override
This event handler can be reimplemented in a subclass to receive paint events passed in event.
void mouseMoveEvent(QMouseEvent *) override
This event handler, for event event, can be reimplemented in a subclass to receive mouse move events ...
QSize sizeHint() const override
void setCrossVisible(bool visible)
void resizeEvent(QResizeEvent *) override
This event handler can be reimplemented in a subclass to receive widget resize events which are passe...
void mousePressEvent(QMouseEvent *) override
This event handler, for event event, can be reimplemented in a subclass to receive mouse press events...
void keyPressEvent(QKeyEvent *event) override
This event handler, for event event, can be reimplemented in a subclass to receive key press events f...
bool eventFilter(QObject *, QEvent *event) override
Filters events if this object has been installed as an event filter for the watched object.
void applicationStateChanged(Qt::ApplicationState state)
QColorPickingEventFilter(QColorDialogPrivate *dp, QObject *parent)
void mouseReleaseEvent(QMouseEvent *e) override
This event handler, for event event, can be reimplemented in a subclass to receive mouse release even...
void mousePressEvent(QMouseEvent *e) override
This event handler, for event event, can be reimplemented in a subclass to receive mouse press events...
void mouseMoveEvent(QMouseEvent *e) override
This event handler, for event event, can be reimplemented in a subclass to receive mouse move events ...
void paintEvent(QPaintEvent *) override
This event handler can be reimplemented in a subclass to receive paint events passed in event.
QColor currentQColor() const
void setHsv(int h, int s, int v)
void currentColorChanged(const QColor &color)
friend class QT_PREPEND_NAMESPACE(QUntypedBindable)
QtPrivate::QColorShower QColorShower
static void rgb2hsv(QRgb rgb, int &h, int &s, int &v)
static int pHeight
static int pWidth
QtPrivate::QColorPickingEventFilter QColorPickingEventFilter
QtPrivate::QColorLuminancePicker QColorLuminancePicker
QtPrivate::QColorPicker QColorPicker
static const Qt::WindowFlags qcd_DefaultWindowFlags
@ colorColumns
@ standardColorRows
@ customColorRows
QT_REQUIRE_CONFIG(colordialog)
#define qApp