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
qgraphicswidget_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 QGRAPHICSWIDGET_P_H
5#define QGRAPHICSWIDGET_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#include <private/qobject_p.h>
20#include "qgraphicsitem_p.h"
21#include "qgraphicswidget.h"
22#include <QtGui/qfont.h>
23#include <QtGui/qpalette.h>
24#include <QtWidgets/qsizepolicy.h>
25#include <QtWidgets/qstyle.h>
26
27#include <memory>
28
29QT_REQUIRE_CONFIG(graphicsview);
30
32
33class QGraphicsLayout;
35
37{
38 Q_DECLARE_PUBLIC(QGraphicsWidget)
39public:
42
43 void init(QGraphicsItem *parentItem, Qt::WindowFlags wFlags);
44 qreal titleBarHeight(const QStyleOptionTitleBar &options) const;
45
46 // Margins
47 mutable std::unique_ptr<QMarginsF> margins;
48 void ensureMargins() const;
49
50 void fixFocusChainBeforeReparenting(QGraphicsWidget *newParent, QGraphicsScene *oldScene, QGraphicsScene *newScene = nullptr);
52
53 // Layouts
57
58 // Style
62 void resolvePalette(uint inheritedMask) override;
63 void updatePalette(const QPalette &palette);
67 void setFont_helper(const QFont &font);
68 void resolveFont(uint inheritedMask) override;
69 void updateFont(const QFont &font);
71
72 // Window specific
74 void adjustWindowFlags(Qt::WindowFlags *wFlags);
80 bool hasDecoration() const;
81
82 // Private Properties
83 qreal width() const override;
84 void setWidth(qreal) override;
85 void resetWidth() override;
86
87 qreal height() const override;
88 void setHeight(qreal) override;
89 void resetHeight() override;
91
92 // State
94 {
95 int bit = -1;
96 switch (att) {
97 case Qt::WA_SetLayoutDirection: bit = 0; break;
98 case Qt::WA_RightToLeft: bit = 1; break;
99 case Qt::WA_SetStyle: bit = 2; break;
100 case Qt::WA_Resized: bit = 3; break;
101 case Qt::WA_DeleteOnClose: bit = 4; break;
102 case Qt::WA_NoSystemBackground: bit = 5; break;
103 case Qt::WA_OpaquePaintEvent: bit = 6; break;
104 case Qt::WA_SetPalette: bit = 7; break;
105 case Qt::WA_SetFont: bit = 8; break;
106 case Qt::WA_WindowPropagation: bit = 9; break;
107 default: break;
108 }
109 return bit;
110 }
112 {
113 int bit = attributeToBitIndex(att);
114 if (bit == -1) {
115 qWarning("QGraphicsWidget::setAttribute: unsupported attribute %d", int(att));
116 return;
117 }
118 if (value)
119 attributes |= (1 << bit);
120 else
121 attributes &= ~(1 << bit);
122 }
123 inline bool testAttribute(Qt::WidgetAttribute att) const
124 {
125 int bit = attributeToBitIndex(att);
126 if (bit == -1)
127 return false;
128 return (attributes & (1 << bit)) != 0;
129 }
135
136 // Focus
140
141 // Windows
142 Qt::WindowFlags windowFlags;
158 std::unique_ptr<WindowData> windowData;
159 void ensureWindowData();
160
162 mutable std::unique_ptr<QMarginsF> windowFrameMargins;
163 void ensureWindowFrameMargins() const;
164
165#ifndef QT_NO_ACTION
166 QList<QAction *> actions;
167#endif
168};
169
171
172#endif //QGRAPHICSWIDGET_P_H
173
\reentrant
Definition qfont.h:22
The QGraphicsItem class is the base class for all graphical items in a QGraphicsScene.
The QGraphicsLayout class provides the base class for all layouts in Graphics View.
The QGraphicsSceneHoverEvent class provides hover events in the graphics view framework.
The QGraphicsSceneMouseEvent class provides mouse events in the graphics view framework.
The QGraphicsScene class provides a surface for managing a large number of 2D graphical items.
void setAttribute(Qt::WidgetAttribute att, bool value)
void windowFrameHoverLeaveEvent(QGraphicsSceneHoverEvent *event)
void setFont_helper(const QFont &font)
QGraphicsWidget * focusPrev
void windowFrameHoverMoveEvent(QGraphicsSceneHoverEvent *event)
std::unique_ptr< QMarginsF > margins
void setWidth(qreal) override
void ensureWindowFrameMargins() const
QGraphicsLayout * layout
void updatePalette(const QPalette &palette)
QList< QAction * > actions
void setLayoutDirection_helper(Qt::LayoutDirection direction)
qreal height() const override
std::unique_ptr< WindowData > windowData
void windowFrameMouseMoveEvent(QGraphicsSceneMouseEvent *event)
bool testAttribute(Qt::WidgetAttribute att) const
qreal titleBarHeight(const QStyleOptionTitleBar &options) const
void updateFont(const QFont &font)
void resolveFont(uint inheritedMask) override
void fixFocusChainBeforeReparenting(QGraphicsWidget *newParent, QGraphicsScene *oldScene, QGraphicsScene *newScene=nullptr)
void setHeight(qreal) override
void init(QGraphicsItem *parentItem, Qt::WindowFlags wFlags)
void initStyleOptionTitleBar(QStyleOptionTitleBar *option)
QPalette naturalWidgetPalette() const
void setPalette_helper(const QPalette &palette)
qreal width() const override
void windowFrameMousePressEvent(QGraphicsSceneMouseEvent *event)
void resolvePalette(uint inheritedMask) override
std::unique_ptr< QMarginsF > windowFrameMargins
void setLayout_helper(QGraphicsLayout *l)
void adjustWindowFlags(Qt::WindowFlags *wFlags)
QGraphicsWidget * focusNext
int attributeToBitIndex(Qt::WidgetAttribute att) const
void windowFrameMouseReleaseEvent(QGraphicsSceneMouseEvent *event)
The QGraphicsWidget class is the base class for all widget items in a QGraphicsScene.
The QPalette class contains color groups for each widget state.
Definition qpalette.h:19
\inmodule QtCore\reentrant
Definition qrect.h:484
\inmodule QtCore\reentrant
Definition qrect.h:30
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
\variable QStyleOptionToolBox::selectedPosition
The QStyle class is an abstract base class that encapsulates the look and feel of a GUI.
Definition qstyle.h:29
SubControl
This enum describes the available sub controls.
Definition qstyle.h:347
direction
Combined button and popup list for selecting options.
Definition qcompare.h:63
WidgetAttribute
Definition qnamespace.h:282
@ WA_SetLayoutDirection
Definition qnamespace.h:323
@ WA_SetPalette
Definition qnamespace.h:303
@ WA_WindowPropagation
Definition qnamespace.h:349
@ WA_RightToLeft
Definition qnamespace.h:322
@ WA_Resized
Definition qnamespace.h:308
@ WA_SetStyle
Definition qnamespace.h:356
@ WA_NoSystemBackground
Definition qnamespace.h:291
@ WA_SetFont
Definition qnamespace.h:304
@ WA_OpaquePaintEvent
Definition qnamespace.h:287
@ WA_DeleteOnClose
Definition qnamespace.h:321
LayoutDirection
FocusPolicy
Definition qnamespace.h:106
WindowFrameSection
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
#define qWarning
Definition qlogging.h:166
struct _cl_event * event
GLuint GLenum option
#define QT_REQUIRE_CONFIG(feature)
unsigned int quint32
Definition qtypes.h:50
unsigned int uint
Definition qtypes.h:34
double qreal
Definition qtypes.h:187