Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qgraphicslayout_p.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
4#ifndef QGRAPHICSLAYOUT_P_H
5#define QGRAPHICSLAYOUT_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists for the convenience
12// of other Qt classes. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtWidgets/private/qtwidgetsglobal_p.h>
19
20#include "qgraphicslayout.h"
22#include <QtWidgets/qstyle.h>
23#include <QtWidgets/qwidget.h>
24#include <QtWidgets/qstyleoption.h>
25
26QT_REQUIRE_CONFIG(graphicsview);
27
29
31class QGraphicsWidget;
32
33#ifdef QT_DEBUG
34inline bool qt_graphicsLayoutDebug()
35{
36 static int checked_env = -1;
37 if (checked_env == -1)
38 checked_env = !!qEnvironmentVariableIntValue("QT_GRAPHICSLAYOUT_DEBUG");
39 return checked_env;
40}
41#endif
42
43
45{
46public:
49 : m_valid(true), m_style(style), m_widget(widget)
50 {
52 if (widget) //###
53 m_styleOption.initFrom(widget);
54 m_defaultSpacing[0] = style->pixelMetric(QStyle::PM_LayoutHorizontalSpacing, &m_styleOption, widget);
55 m_defaultSpacing[1] = style->pixelMetric(QStyle::PM_LayoutVerticalSpacing, &m_styleOption, widget);
56 }
57
58 inline void invalidate() { m_valid = false; m_style = nullptr; m_widget = nullptr; }
59
60 inline QStyle *style() const { return m_style; }
61 inline QWidget *widget() const { return m_widget; }
62
63 inline bool operator==(const QLayoutStyleInfo &other) const
64 { return m_style == other.m_style && m_widget == other.m_widget; }
65 inline bool operator!=(const QLayoutStyleInfo &other) const
66 { return !(*this == other); }
67
69 if (spacing >= 0)
70 m_defaultSpacing[int(o) - 1] = spacing;
71 }
72
74 return m_defaultSpacing[int(o) - 1];
75 }
76
79 Qt::Orientation orientation) const
80 {
81 Q_ASSERT(style());
82 return style()->layoutSpacing(control1, control2, orientation, &m_styleOption, widget());
83 }
84private:
85 bool m_valid;
86 QStyle *m_style;
87 QWidget *m_widget;
88 QStyleOption m_styleOption;
89 qreal m_defaultSpacing[2];
90};
91
93{
94 Q_DECLARE_PUBLIC(QGraphicsLayout)
95
96public:
98 activated(true) { }
99
100 void reparentChildItems(QGraphicsItem *newParent);
101 void getMargin(qreal *result, qreal userMargin, QStyle::PixelMetric pm) const;
102 Qt::LayoutDirection visualDirection() const;
103
104 void addChildLayoutItem(QGraphicsLayoutItem *item);
105 void activateRecursive(QGraphicsLayoutItem *item);
106
109};
110
112
113#endif
The QGraphicsItem class is the base class for all graphical items in a QGraphicsScene.
The QGraphicsLayoutItem class can be inherited to allow your custom items to be managed by layouts.
The QGraphicsLayout class provides the base class for all layouts in Graphics View.
The QGraphicsWidget class is the base class for all widget items in a QGraphicsScene.
void setDefaultSpacing(Qt::Orientation o, qreal spacing)
bool operator==(const QLayoutStyleInfo &other) const
bool operator!=(const QLayoutStyleInfo &other) const
qreal perItemSpacing(QSizePolicy::ControlType control1, QSizePolicy::ControlType control2, Qt::Orientation orientation) const
qreal defaultSpacing(Qt::Orientation o) const
QWidget * widget() const
QStyle * style() const
QLayoutStyleInfo(QStyle *style, QWidget *widget)
The QStyleOption class stores the parameters used by QStyle functions.
void initFrom(const QWidget *w)
The QStyle class is an abstract base class that encapsulates the look and feel of a GUI.
Definition qstyle.h:29
virtual int layoutSpacing(QSizePolicy::ControlType control1, QSizePolicy::ControlType control2, Qt::Orientation orientation, const QStyleOption *option=nullptr, const QWidget *widget=nullptr) const =0
PixelMetric
This enum describes the various available pixel metrics.
Definition qstyle.h:413
@ PM_LayoutVerticalSpacing
Definition qstyle.h:517
@ PM_LayoutHorizontalSpacing
Definition qstyle.h:516
virtual int pixelMetric(PixelMetric metric, const QStyleOption *option=nullptr, const QWidget *widget=nullptr) const =0
Returns the value of the given pixel metric.
The QWidget class is the base class of all user interface objects.
Definition qwidget.h:99
qreal spacing
Combined button and popup list for selecting options.
LayoutDirection
Orientation
Definition qnamespace.h:98
GLdouble GLdouble GLdouble GLdouble top
GLdouble GLdouble right
GLint left
GLint GLint bottom
GLuint64EXT * result
[6]
#define Q_ASSERT(cond)
Definition qrandom.cpp:47
#define Q_AUTOTEST_EXPORT
#define QT_REQUIRE_CONFIG(feature)
Q_CORE_EXPORT int qEnvironmentVariableIntValue(const char *varName, bool *ok=nullptr) noexcept
double qreal
Definition qtypes.h:187
QObject::connect nullptr
QSharedPointer< T > other(t)
[5]
QGraphicsItem * item