50 #include <private/qaction_p.h>
52 #include <private/qapplication_p.h>
53 #include <private/qgraphicsscene_p.h>
54 #ifndef QT_NO_SHORTCUT
55 #include <private/qshortcutmap_p.h>
57 #include <QtCore/qmutex.h>
58 #include <QtCore/QScopeGuard>
59 #include <QtWidgets/qapplication.h>
60 #include <QtWidgets/qgraphicsview.h>
61 #include <QtWidgets/qgraphicsproxywidget.h>
62 #include <QtGui/qpalette.h>
63 #include <QtGui/qpainterpath.h>
64 #include <QtWidgets/qstyleoption.h>
236 for (
auto action : qAsConst(
d->actions)) {
248 d->focusPrev->d_func()->focusNext =
d->focusNext;
249 d->focusNext->d_func()->focusPrev =
d->focusPrev;
260 const auto items = childItems();
267 if (
widget->parentLayoutItem() ==
d->layout)
268 widget->setParentLayoutItem(
nullptr);
276 widgetStyles()->setStyleForWidget(
this,
nullptr);
281 setParentItem(
nullptr);
358 const auto relayoutChildren =
qScopeGuard([
this, wd]() {
361 if (!lay->isActivated()) {
362 QEvent layoutRequest(QEvent::LayoutRequest);
363 QCoreApplication::sendEvent(this, &layoutRequest);
378 if (newGeom ==
d->geom)
382 wd->inSetGeometry = 1;
384 wd->inSetGeometry = 0;
387 if (newGeom ==
d->geom)
392 if (wd->scene &&
rect.topLeft() ==
d->geom.topLeft())
393 prepareGeometryChange();
397 if (oldPos !=
pos()) {
400 event.setOldPos(oldPos);
401 event.setNewPos(
pos());
405 d->geom.moveTopLeft(
pos());
406 emit geometryChanged();
414 if (newGeom.
size() != oldSize) {
418 emit heightChanged();
428 emit geometryChanged();
491 if (!
d->margins && margins.
isNull())
494 if (*
d->margins == margins)
497 *
d->margins = margins;
532 *
left =
d->margins->left();
534 *
top =
d->margins->top();
536 *
right =
d->margins->right();
538 *
bottom =
d->margins->bottom();
556 if (!
d->windowFrameMargins && margins.
isNull())
558 d->ensureWindowFrameMargins();
559 const bool unchanged = *
d->windowFrameMargins == margins;
560 if (
d->setWindowFrameMargins && unchanged)
564 *
d->windowFrameMargins = margins;
565 d->setWindowFrameMargins =
true;
589 d->ensureWindowFrameMargins();
591 *
left =
d->windowFrameMargins->left();
593 *
top =
d->windowFrameMargins->top();
595 *
right =
d->windowFrameMargins->right();
597 *
bottom =
d->windowFrameMargins->bottom();
611 d->initStyleOptionTitleBar(&bar);
614 qreal titleBarHeight =
d->titleBarHeight(bar);
619 d->setWindowFrameMargins =
false;
631 return d->windowFrameMargins
633 d->windowFrameMargins->right(),
d->windowFrameMargins->bottom())
645 return d->windowFrameMargins
646 ?
rect().
adjusted(-
d->windowFrameMargins->left(), -
d->windowFrameMargins->top(),
647 d->windowFrameMargins->right(),
d->windowFrameMargins->bottom())
707 if (
w->isActiveWindow())
743 marginSize =
QSizeF(
d->margins->left() +
d->margins->right(),
744 d->margins->top() +
d->margins->bottom());
746 sh =
d->layout->effectiveSizeHint(which, constraint - marginSize);
760 qWarning(
"QGraphicsWidget::sizeHint(): Don't know how to handle the value of 'which'");
830 d->setLayout_helper(
l);
836 if (oldParent && oldParent !=
this) {
837 qWarning(
"QGraphicsWidget::setLayout: Attempting to set a layout on %s"
838 " \"%s\", when the layout already has a parent",
844 l->setParentLayoutItem(
this);
845 l->d_func()->reparentChildItems(
this);
906 d->resolveLayoutDirection();
919 if (
QStyle *
style = widgetStyles()->styleForWidget(
this))
941 widgetStyles()->setStyleForWidget(
this,
style);
982 QFont naturalFont =
d->naturalWidgetFont();
984 d->setFont_helper(resolvedFont);
1022 QPalette naturalPalette =
d->naturalWidgetPalette();
1024 d->setPalette_helper(resolvedPalette);
1046 return d->autoFillBackground;
1051 if (
d->autoFillBackground !=
enabled) {
1131 if (
value.toBool()) {
1143 if (
value.toBool() ||
d->explicitlyHidden)
1147 if (!
value.toBool()) {
1154 d->setGeometryFromSetPos();
1250 switch (
event->type()) {
1255 d->ensureWindowData();
1273 return event->isAccepted();
1299 if (!
r.contains(
pos))
1309 const qreal cornerMargin = 20;
1311 const qreal windowFrameWidth =
d->windowFrameMargins
1312 ?
d->windowFrameMargins->left() : 0;
1315 if (
x <=
left + cornerMargin) {
1316 if (
y <=
top + windowFrameWidth || (
x <=
left + windowFrameWidth &&
y <=
top + cornerMargin)) {
1320 }
else if (
x <=
left + windowFrameWidth) {
1323 }
else if (
x >=
right - cornerMargin) {
1324 if (
y <=
top + windowFrameWidth || (
x >=
right - windowFrameWidth &&
y <=
top + cornerMargin)) {
1326 }
else if (
y >=
bottom - windowFrameWidth || (
x >=
right - windowFrameWidth &&
y >=
bottom - cornerMargin)) {
1328 }
else if (
x >=
right - windowFrameWidth) {
1331 }
else if (
y <=
top + windowFrameWidth) {
1333 }
else if (
y >=
bottom - windowFrameWidth) {
1339 ?
d->windowFrameMargins->top() : 0);
1388 d->layout->widgetEvent(
event);
1391 switch (
event->type()) {
1408 d->updateFont(
d->font);
1453 d->ensureWindowData();
1454 if (
d->hasDecoration() &&
d->windowData->grabbedSection !=
Qt::NoSection)
1460 if (
d->hasDecoration()) {
1487 switch (
event->type()) {
1492 d->layout->invalidate();
1502 d->resolveFont(
d->inheritedFontResolveMask);
1503 d->resolvePalette(
d->inheritedPaletteResolveMask);
1560 if (
d->scene->focusNextPrevChild(
next))
1760 return d->windowFlags;
1765 if (
d->windowFlags == wFlags)
1769 d->adjustWindowFlags(&wFlags);
1770 d->windowFlags = wFlags;
1771 if (!
d->setWindowFrameMargins)
1777 if (
d->scene &&
isVisible() && wasPopup != isPopup) {
1780 d->scene->d_func()->removePopup(
this);
1782 d->scene->d_func()->addPopup(
this);
1785 if (
d->scene &&
d->scene->d_func()->allItemsIgnoreHoverEvents &&
d->hasDecoration()) {
1786 d->scene->d_func()->allItemsIgnoreHoverEvents =
false;
1787 d->scene->d_func()->enableMouseTrackingOnViews();
1818 d->ensureWindowData();
1819 d->windowData->windowTitle =
title;
1824 return d->windowData ?
d->windowData->windowTitle :
QString();
1850 return d->focusPolicy;
1873 if (
d->subFocusItem &&
d->subFocusItem->d_ptr->isWidget)
1878 #ifndef QT_NO_SHORTCUT
1976 #ifndef QT_NO_ACTION
2024 qWarning(
"QWidget::insertAction: Attempt to insert null action");
2031 d->actions.removeAt(
index);
2033 int pos =
d->actions.indexOf(before);
2036 pos =
d->actions.size();
2083 if (
d->actions.removeAll(
action)) {
2130 if (!
first && !second) {
2131 qWarning(
"QGraphicsWidget::setTabOrder(0, 0) is undefined");
2135 qWarning(
"QGraphicsWidget::setTabOrder: scenes %p and %p are different",
2141 qWarning(
"QGraphicsWidget::setTabOrder: assigning tab order from/to the"
2142 " scene requires the item to be in a scene.");
2161 if (firstFocusNext == second) {
2169 firstFocusNext->d_func()->focusPrev = second;
2170 first->d_func()->focusNext = second;
2171 second->d_func()->focusNext = firstFocusNext;
2172 second->d_func()->focusPrev =
first;
2173 secondFocusPrev->d_func()->focusNext = secondFocusNext;
2174 secondFocusNext->d_func()->focusPrev = secondFocusPrev;
2179 Q_ASSERT(second->d_func()->focusNext->d_func()->focusPrev == second);
2180 Q_ASSERT(second->d_func()->focusPrev->d_func()->focusNext == second);
2257 const bool embeddedWidgetFillsOwnBackground =
proxy &&
proxy->widget();
2260 if (fillBackground && !embeddedWidgetFillsOwnBackground)
2269 bar.QStyleOption::operator=(*option);
2270 d->initStyleOptionTitleBar(&bar);
2271 d->ensureWindowData();
2282 if (pixmapSize.
width() <= 0 || pixmapSize.
height() <= 0)
2298 if (fillBackground) {
2299 if (embeddedWidgetFillsOwnBackground) {
2305 windowFrameBackground.
addRect(
rect().translated(-styleOrigin).adjusted(0.5, 0.5, -0.5, -0.5));
2313 int height = (int)
d->titleBarHeight(bar);
2316 bar.
rect.
adjust(frameWidth, frameWidth, -frameWidth, 0);
2326 frameOptions.QStyleOption::operator=(*option);
2393 void QGraphicsWidget::dumpFocusChain()
2395 qDebug(
"=========== Dumping focus chain ==============");
2401 qWarning(
"Found a focus chain that is not circular, (next == 0)");
2406 qWarning(
"Already visited this node. However, I expected to dump until I found myself.");
2411 }
while (
next !=
this);
2417 #include "moc_qgraphicswidget.cpp"
small capitals from c petite p scientific i
[1]
The QActionEvent class provides an event that is generated when a QAction is added,...
The QAction class provides an abstraction for user commands that can be added to different user inter...
QObjectList associatedObjects
The QCloseEvent class contains parameters that describe a close event.
static bool sendEvent(QObject *receiver, QEvent *event)
static void postEvent(QObject *receiver, QEvent *event, int priority=Qt::NormalEventPriority)
The QEvent class is the base class of all event classes. Event objects contain event parameters.
@ GraphicsSceneMouseRelease
@ GraphicsSceneMousePress
@ GraphicsSceneHoverLeave
@ GraphicsSceneMouseDoubleClick
@ GraphicsSceneHoverEnter
The QFocusEvent class contains event parameters for widget focus events. \inmodule QtGui.
The QFont class specifies a query for a font used for drawing text.
QFont resolve(const QFont &) const
void setResolveMask(uint mask)
The QFontMetrics class provides font metrics information.
The QGraphicsItem class is the base class for all graphical items in a QGraphicsScene.
virtual bool contains(const QPointF &point) const
friend class QGraphicsWidget
void update(const QRectF &rect=QRectF())
QGraphicsWidget * parentWidget() const
virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value)
QGraphicsScene * scene() const
QGraphicsWidget * window() const
bool acceptHoverEvents() const
bool isUnderMouse() const
void prepareGeometryChange()
void setFlag(GraphicsItemFlag flag, bool enabled=true)
virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
QGraphicsItem * parentItem() const
void setFocus(Qt::FocusReason focusReason=Qt::OtherFocusReason)
virtual bool sceneEvent(QEvent *event)
The QGraphicsLayout class provides the base class for all layouts in Graphics View.
static bool instantInvalidatePropagation()
The QGraphicsLayoutItem class can be inherited to allow your custom items to be managed by layouts.
QSizeF effectiveSizeHint(Qt::SizeHint which, const QSizeF &constraint=QSizeF()) const
QScopedPointer< QGraphicsLayoutItemPrivate > d_ptr
virtual void updateGeometry()
QGraphicsLayoutItem * parentLayoutItem() const
virtual void setGeometry(const QRectF &rect)
The QGraphicsObject class provides a base class for all graphics items that require signals,...
bool enabled
whether the item is enabled or not
QPointF pos
the position of the item
QGraphicsObject * parent
the parent of the item
The QGraphicsSceneHoverEvent class provides hover events in the graphics view framework.
The QGraphicsScene class provides a surface for managing a large number of 2D graphical items.
The QGraphicsSceneMouseEvent class provides mouse events in the graphics view framework.
The QGraphicsSceneMoveEvent class provides events for widget moving in the graphics view framework.
QGraphicsWidget * tabFocusFirst
The QGraphicsSceneResizeEvent class provides events for widget resizing in the graphics view framewor...
void setOldSize(const QSizeF &size)
void setNewSize(const QSizeF &size)
static QGuiApplicationPrivate * instance()
bool remove(const Key &key)
T value(const Key &key) const noexcept
The QHideEvent class provides an event which is sent after a widget is hidden.
The QKeySequence class encapsulates a key sequence as used by shortcuts.
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal.
const_reference at(qsizetype i) const noexcept
qsizetype removeAll(const AT &t)
qsizetype count() const noexcept
void append(parameter_type t)
The QMarginsF class defines the four margins of a rectangle.
constexpr bool isNull() const noexcept
The QMutex class provides access serialization between threads.
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes.
QString objectName
the name of this object
virtual bool event(QEvent *event)
The QPainter class performs low-level painting on widgets and other paint devices.
void setClipRect(const QRectF &, Qt::ClipOperation op=Qt::ReplaceClip)
void setFont(const QFont &f)
void drawPixmap(const QRectF &targetRect, const QPixmap &pixmap, const QRectF &sourceRect)
void fillPath(const QPainterPath &path, const QBrush &brush)
void translate(const QPointF &offset)
void fillRect(const QRectF &, const QBrush &)
void setClipRegion(const QRegion &, Qt::ClipOperation op=Qt::ReplaceClip)
The QPainterPath class provides a container for painting operations, enabling graphical shapes to be ...
void addRect(const QRectF &rect)
The QPalette class contains color groups for each widget state.
void setCurrentColorGroup(ColorGroup cg)
ResolveMask resolveMask() const
QPalette resolve(const QPalette &other) const
The QPixmap class is an off-screen image representation that can be used as a paint device.
The QPointF class defines a point in the plane using floating point precision.
constexpr qreal x() const noexcept
constexpr qreal y() const noexcept
The QPoint class defines a point in the plane using integer precision.
The QRectF class defines a finite rectangle in the plane using floating point precision.
constexpr void moveTopLeft(const QPointF &p) noexcept
constexpr QRectF adjusted(qreal x1, qreal y1, qreal x2, qreal y2) const noexcept
constexpr void setSize(const QSizeF &s) noexcept
constexpr QPointF topLeft() const noexcept
constexpr QSizeF size() const noexcept
constexpr QRect toRect() const noexcept
The QRect class defines a rectangle in the plane using integer precision.
constexpr void adjust(int x1, int y1, int x2, int y2) noexcept
bool contains(const QRect &r, bool proper=false) const noexcept
constexpr void setHeight(int h) noexcept
T * data() const noexcept
bool contains(const T &value) const
The QShowEvent class provides an event that is sent when a widget is shown.
The QSizeF class defines the size of a two-dimensional object using floating point precision.
constexpr bool isValid() const noexcept
constexpr qreal width() const noexcept
constexpr qreal height() const noexcept
The QSize class defines the size of a two-dimensional object using integer point precision.
constexpr int height() const noexcept
constexpr int width() const noexcept
The QString class provides a Unicode character string.
static QString fromLatin1(QByteArrayView ba)
QString arg(qlonglong a, int fieldwidth=0, int base=10, QChar fillChar=QLatin1Char(' ')) const
static QString number(int, int base=10)
The QStyleHintReturnMask class provides style hints that return a QRegion.
The QStyle class is an abstract base class that encapsulates the look and feel of a GUI.
virtual void drawComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, QPainter *p, const QWidget *widget=nullptr) const =0
virtual int styleHint(StyleHint stylehint, const QStyleOption *opt=nullptr, const QWidget *widget=nullptr, QStyleHintReturn *returnData=nullptr) const =0
@ PM_MdiSubWindowFrameWidth
virtual int pixelMetric(PixelMetric metric, const QStyleOption *option=nullptr, const QWidget *widget=nullptr) const =0
virtual void drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPainter *p, const QWidget *w=nullptr) const =0
the background color on which the focus rectangle is being drawn
The QStyleOptionGraphicsItem class is used to describe the parameters needed to draw a QGraphicsItem.
The QStyleOption class stores the parameters used by QStyle functions.
the position of the selected tab in relation to this tab
The QVariant class acts like a union for the most common Qt data types.
EGLOutputLayerEXT EGLint EGLAttrib value
EGLOutputLayerEXT EGLint attribute
QT_END_INCLUDE_NAMESPACE typedef double qreal
#define Q_GLOBAL_STATIC(TYPE, NAME,...)
GLint GLint GLint GLint GLint x
[0]
GLfloat GLfloat GLfloat w
[0]
GLint GLsizei GLsizei height
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLdouble GLdouble GLdouble GLdouble top
GLenum GLenum GLsizei const GLuint GLboolean enabled
GLint GLint GLint GLint GLint GLint GLint GLbitfield mask
GLsizei const GLchar *const * path
QScopeGuard< typename std::decay< F >::type > qScopeGuard(F &&f)
[qScopeGuard]
const char className[16]
[1]
obj metaObject() -> className()
app setAttribute(Qt::AA_DontShowIconsInMenus)
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent