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
zoomwidget_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 GPL-3.0-only WITH Qt-GPL-exception-1.0
3
4
//
5
// W A R N I N G
6
// -------------
7
//
8
// This file is not part of the Qt API. It exists for the convenience
9
// of Qt Designer. This header
10
// file may change from version to version without notice, or even be removed.
11
//
12
// We mean it.
13
//
14
15
#
ifndef
ZOOMWIDGET_H
16
#
define
ZOOMWIDGET_H
17
18
#
include
"shared_global_p.h"
19
20
#
include
<
QtWidgets
/
qgraphicsview
.
h
>
21
#
include
<
QtWidgets
/
qgraphicsproxywidget
.
h
>
22
23
#
include
<
QtCore
/
qlist
.
h
>
24
25
QT_BEGIN_NAMESPACE
26
27
class
QGraphicsScene;
28
class
QMenu;
29
class
QAction;
30
class
QActionGroup;
31
32
namespace
qdesigner_internal
{
33
34
// A checkable zoom menu action group. Operates in percent.
35
36
class
QDESIGNER_SHARED_EXPORT
ZoomMenu
:
public
QObject
{
37
Q_OBJECT
38
Q_DISABLE_COPY_MOVE
(
ZoomMenu
)
39
40
public
:
41
ZoomMenu
(
QObject
*
parent
=
nullptr
);
42
void
addActions
(
QMenu
*
m
);
43
44
int
zoom
()
const
;
45
46
// Return a list of available zoom values.
47
static
QList
<
int
>
zoomValues
();
48
49
public
slots
:
50
void
setZoom
(
int
percent
);
51
52
signals
:
53
void
zoomChanged
(
int
);
54
55
private
slots
:
56
void
slotZoomMenu
(
QAction
*);
57
58
private
:
59
static
int
zoomOf
(
const
QAction
*
a
);
60
61
QActionGroup
*
m_menuActions
;
62
};
63
64
/* Zoom view: A QGraphicsView with a zoom menu */
65
66
class
QDESIGNER_SHARED_EXPORT
ZoomView
:
public
QGraphicsView
67
{
68
Q_PROPERTY
(
int
zoom
READ
zoom
WRITE
setZoom
DESIGNABLE
true
SCRIPTABLE
true
)
69
Q_PROPERTY
(
bool
zoomContextMenuEnabled
READ
isZoomContextMenuEnabled
WRITE
setZoomContextMenuEnabled
DESIGNABLE
true
SCRIPTABLE
true
)
70
Q_OBJECT
71
Q_DISABLE_COPY_MOVE
(
ZoomView
)
72
public
:
73
ZoomView
(
QWidget
*
parent
=
nullptr
);
74
75
/* Zoom in percent (for easily implementing menus) and qreal zoomFactor
76
* in sync */
77
int
zoom
()
const
;
// in percent
78
qreal
zoomFactor
()
const
;
79
80
// Zoom Menu on QGraphicsView.
81
bool
isZoomContextMenuEnabled
()
const
;
82
void
setZoomContextMenuEnabled
(
bool
e
);
83
84
QGraphicsScene
&
scene
() {
return
*
m_scene
; }
85
const
QGraphicsScene
&
scene
()
const
{
return
*
m_scene
; }
86
87
// Helpers for menu
88
ZoomMenu
*
zoomMenu
();
89
90
QPoint
scrollPosition
()
const
;
91
void
setScrollPosition
(
const
QPoint
&
pos
);
92
void
scrollToOrigin
();
93
94
public
slots
:
95
void
setZoom
(
int
percent
);
96
void
showContextMenu
(
const
QPoint
&
globalPos
);
97
98
protected
:
99
void
contextMenuEvent
(
QContextMenuEvent
*
event
)
override
;
100
101
// Overwrite for implementing additional behaviour when doing setZoom();
102
virtual
void
applyZoom
();
103
104
private
:
105
QGraphicsScene
*
m_scene
;
106
int
m_zoom
= 100;
107
qreal
m_zoomFactor
= 1;
108
109
bool
m_zoomContextMenuEnabled
=
false
;
110
ZoomMenu
*
m_zoomMenu
=
nullptr
;
111
};
112
113
/* The proxy widget used in ZoomWidget. It refuses to move away from 0,0,
114
* This behaviour is required for Windows only. */
115
116
class
QDESIGNER_SHARED_EXPORT
ZoomProxyWidget
:
public
QGraphicsProxyWidget
{
117
Q_DISABLE_COPY_MOVE
(
ZoomProxyWidget
)
118
public
:
119
explicit
ZoomProxyWidget
(
QGraphicsItem
*
parent
=
nullptr
,
Qt
::
WindowFlags
wFlags
= {});
120
121
protected
:
122
QVariant
itemChange
(
GraphicsItemChange
change
,
const
QVariant
&
value
)
override
;
123
};
124
125
/* Zoom widget: A QGraphicsView-based container for a widget that allows for
126
* zooming it. Communicates changes in size in the following ways:
127
* 1) Embedded widget wants to resize: Listen for its resize in event filter
128
* and resize
129
* 2) Zoom is changed: resize to fully display the embedded widget
130
* 3) Outer widget changes (by manually resizing the window:
131
* Pass the scaled change on to the embedded widget.
132
* Provides helper functions for a zoom context menu on the widget. */
133
134
class
QDESIGNER_SHARED_EXPORT
ZoomWidget
:
public
ZoomView
135
{
136
Q_PROPERTY
(
bool
widgetZoomContextMenuEnabled
READ
isWidgetZoomContextMenuEnabled
WRITE
setWidgetZoomContextMenuEnabled
DESIGNABLE
true
SCRIPTABLE
true
)
137
Q_PROPERTY
(
bool
itemAcceptDrops
READ
itemAcceptDrops
WRITE
setItemAcceptDrops
DESIGNABLE
true
SCRIPTABLE
true
)
138
Q_OBJECT
139
Q_DISABLE_COPY_MOVE
(
ZoomWidget
)
140
141
public
:
142
ZoomWidget
(
QWidget
*
parent
=
nullptr
);
143
void
setWidget
(
QWidget
*
w
,
Qt
::
WindowFlags
wFlags
= {});
144
145
const
QGraphicsProxyWidget
*
proxy
()
const
{
return
m_proxy
; }
146
QGraphicsProxyWidget
*
proxy
() {
return
m_proxy
; }
147
148
/* Enable the zoom Menu on the Widget (as opposed ZoomView's menu which
149
* is on the canvas). */
150
bool
isWidgetZoomContextMenuEnabled
()
const
;
151
void
setWidgetZoomContextMenuEnabled
(
bool
e
);
152
153
void
setItemAcceptDrops
(
bool
);
154
bool
itemAcceptDrops
()
const
;
155
156
QSize
minimumSizeHint
()
const
override
;
157
QSize
sizeHint
()
const
override
;
158
159
bool
zoomedEventFilter
(
QObject
*
watched
,
QEvent
*
event
);
160
161
public
slots
:
162
// debug state
163
void
dump
()
const
;
164
165
protected
:
166
void
resizeEvent
(
QResizeEvent
*
event
)
override
;
167
168
// Overwritten from ZoomView
169
void
applyZoom
()
override
;
170
// Overwrite to actually perform a resize. This is required if we are in a layout. Default does resize().
171
virtual
void
doResize
(
const
QSize
&
s
);
172
173
private
:
174
// Factory function for QGraphicsProxyWidgets which can be overwritten. Default creates a ZoomProxyWidget
175
virtual
QGraphicsProxyWidget
*
createProxyWidget
(
QGraphicsItem
*
parent
=
nullptr
,
176
Qt
::
WindowFlags
wFlags
= {})
const
;
177
QSize
widgetSizeToViewSize
(
const
QSize
&
s
,
bool
*
ptrToValid
=
nullptr
)
const
;
178
179
void
resizeToWidgetSize
();
180
QSize
viewPortMargin
()
const
;
181
QSize
widgetSize
()
const
;
182
QSizeF
widgetDecorationSizeF
()
const
;
183
184
QGraphicsProxyWidget
*
m_proxy
=
nullptr
;
185
bool
m_viewResizeBlocked
=
false
;
186
bool
m_widgetResizeBlocked
=
false
;
187
bool
m_widgetZoomContextMenuEnabled
=
false
;
188
};
189
190
}
// namespace qdesigner_internal
191
192
QT_END_NAMESPACE
193
194
#
endif
QPaintEngine::QPainter
friend class QPainter
Definition
qpaintengine.h:219
QPainter::QWidget
friend class QWidget
Definition
qpainter.h:423
qdesigner_internal::FormEditorOptionsPage
Definition
formeditor_optionspage.h:22
qdesigner_internal::FormEditorOptionsPage::FormEditorOptionsPage
FormEditorOptionsPage(QDesignerFormEditorInterface *core)
Definition
formeditor_optionspage.cpp:79
qdesigner_internal::FormEditorOptionsPage::name
QString name() const override
Definition
formeditor_optionspage.cpp:84
qdesigner_internal::FormEditorOptionsPage::finish
void finish() override
Definition
formeditor_optionspage.cpp:169
qdesigner_internal::FormEditorOptionsPage::apply
void apply() override
Definition
formeditor_optionspage.cpp:136
qdesigner_internal::GridPanel
Definition
gridpanel_p.h:33
qdesigner_internal::Grid
Definition
grid_p.h:33
qdesigner_internal::PreviewConfigurationWidget
Definition
previewconfigurationwidget_p.h:33
qdesigner_internal::QDesignerSharedSettings
Definition
shared_settings_p.h:42
qdesigner_internal::ZoomMenu
Definition
zoomwidget_p.h:36
qdesigner_internal::ZoomProxyWidget
Definition
zoomwidget_p.h:116
qdesigner_internal::ZoomSettingsWidget
Definition
formeditor_optionspage.cpp:31
qdesigner_internal::ZoomSettingsWidget::fromSettings
void fromSettings(const QDesignerSharedSettings &s)
Definition
formeditor_optionspage.cpp:62
qdesigner_internal::ZoomSettingsWidget::toSettings
void toSettings(QDesignerSharedSettings &s) const
Definition
formeditor_optionspage.cpp:69
qdesigner_internal::ZoomView
Definition
zoomwidget_p.h:67
qdesigner_internal::ZoomWidget
Definition
zoomwidget_p.h:135
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qstandardpaths_haiku.cpp:21
qdesigner_internal::Ui
Definition
templateoptionspage.h:20
qdesigner_internal
Auxiliary methods to store/retrieve settings.
Definition
buddyeditor.cpp:66
qdesigner_internal::ObjectNamingMode
ObjectNamingMode
Definition
shared_enums_p.h:57
QDESIGNER_SHARED_EXPORT
#define QDESIGNER_SHARED_EXPORT
Definition
shared_global_p.h:32
qttools
src
designer
src
lib
shared
zoomwidget_p.h
Generated on Mon Mar 10 2025 00:53:42 for Qt by
1.13.2