14#include <private/qaction_p.h>
16#include <private/qapplication_p.h>
17#include <private/qgraphicsscene_p.h>
19#include <private/qshortcutmap_p.h>
21#include <QtCore/qmutex.h>
22#include <QtCore/QScopeGuard>
23#include <QtWidgets/qapplication.h>
24#include <QtWidgets/qgraphicsview.h>
25#include <QtWidgets/qgraphicsproxywidget.h>
26#include <QtGui/qpalette.h>
27#include <QtGui/qpainterpath.h>
28#include <QtWidgets/qstyleoption.h>
202 for (
auto action : std::as_const(
d->actions)) {
214 d->focusPrev->d_func()->focusNext =
d->focusNext;
215 d->focusNext->d_func()->focusPrev =
d->focusPrev;
226 const auto items = childItems();
233 if (
widget->parentLayoutItem() ==
d->layout)
234 widget->setParentLayoutItem(
nullptr);
242 widgetStyles()->setStyleForWidget(
this,
nullptr);
247 setParentItem(
nullptr);
324 const auto relayoutChildren =
qScopeGuard([
this, wd]() {
327 if (!lay->isActivated()) {
328 QEvent layoutRequest(QEvent::LayoutRequest);
329 QCoreApplication::sendEvent(this, &layoutRequest);
344 if (newGeom ==
d->geom)
348 wd->inSetGeometry = 1;
350 wd->inSetGeometry = 0;
353 if (newGeom ==
d->geom)
358 if (wd->scene &&
rect.topLeft() ==
d->geom.topLeft())
359 prepareGeometryChange();
363 if (oldPos !=
pos()) {
366 event.setOldPos(oldPos);
367 event.setNewPos(
pos());
371 d->geom.moveTopLeft(
pos());
372 emit geometryChanged();
380 if (newGeom.
size() != oldSize) {
384 emit heightChanged();
394 emit geometryChanged();
457 if (!
d->margins && margins.
isNull())
460 if (*
d->margins == margins)
463 *
d->margins = margins;
498 *
left =
d->margins->left();
500 *
top =
d->margins->top();
502 *
right =
d->margins->right();
504 *
bottom =
d->margins->bottom();
522 if (!
d->windowFrameMargins && margins.
isNull())
524 d->ensureWindowFrameMargins();
525 const bool unchanged = *
d->windowFrameMargins == margins;
526 if (
d->setWindowFrameMargins && unchanged)
530 *
d->windowFrameMargins = margins;
531 d->setWindowFrameMargins =
true;
555 d->ensureWindowFrameMargins();
557 *
left =
d->windowFrameMargins->left();
559 *
top =
d->windowFrameMargins->top();
561 *
right =
d->windowFrameMargins->right();
563 *
bottom =
d->windowFrameMargins->bottom();
577 d->initStyleOptionTitleBar(&bar);
580 qreal titleBarHeight =
d->titleBarHeight(bar);
585 d->setWindowFrameMargins =
false;
597 return d->windowFrameMargins
599 d->windowFrameMargins->right(),
d->windowFrameMargins->bottom())
611 return d->windowFrameMargins
612 ?
rect().
adjusted(-
d->windowFrameMargins->left(), -
d->windowFrameMargins->top(),
613 d->windowFrameMargins->right(),
d->windowFrameMargins->bottom())
673 if (
w->isActiveWindow())
709 marginSize =
QSizeF(
d->margins->left() +
d->margins->right(),
710 d->margins->top() +
d->margins->bottom());
712 sh =
d->layout->effectiveSizeHint(which, constraint - marginSize);
726 qWarning(
"QGraphicsWidget::sizeHint(): Don't know how to handle the value of 'which'");
796 d->setLayout_helper(l);
802 if (oldParent && oldParent !=
this) {
803 qWarning(
"QGraphicsWidget::setLayout: Attempting to set a layout on %s"
804 " \"%s\", when the layout already has a parent",
811 l->d_func()->reparentChildItems(
this);
872 d->resolveLayoutDirection();
885 if (
QStyle *
style = widgetStyles()->styleForWidget(
this))
907 widgetStyles()->setStyleForWidget(
this,
style);
948 QFont naturalFont =
d->naturalWidgetFont();
950 d->setFont_helper(resolvedFont);
988 QPalette naturalPalette =
d->naturalWidgetPalette();
990 d->setPalette_helper(resolvedPalette);
1012 return d->autoFillBackground;
1017 if (
d->autoFillBackground !=
enabled) {
1097 if (
value.toBool()) {
1109 if (
value.toBool() ||
d->explicitlyHidden)
1113 if (!
value.toBool()) {
1120 d->setGeometryFromSetPos();
1216 switch (
event->type()) {
1221 d->ensureWindowData();
1239 return event->isAccepted();
1265 if (!
r.contains(
pos))
1275 const qreal cornerMargin = 20;
1277 const qreal windowFrameWidth =
d->windowFrameMargins
1278 ?
d->windowFrameMargins->left() : 0;
1281 if (
x <=
left + cornerMargin) {
1282 if (
y <=
top + windowFrameWidth || (
x <=
left + windowFrameWidth &&
y <=
top + cornerMargin)) {
1284 }
else if (
y >=
bottom - windowFrameWidth || (x <= left + windowFrameWidth && y >=
bottom - cornerMargin)) {
1286 }
else if (
x <=
left + windowFrameWidth) {
1289 }
else if (
x >=
right - cornerMargin) {
1290 if (
y <=
top + windowFrameWidth || (
x >=
right - windowFrameWidth &&
y <=
top + cornerMargin)) {
1292 }
else if (
y >=
bottom - windowFrameWidth || (
x >=
right - windowFrameWidth &&
y >=
bottom - cornerMargin)) {
1294 }
else if (
x >=
right - windowFrameWidth) {
1297 }
else if (
y <=
top + windowFrameWidth) {
1299 }
else if (
y >=
bottom - windowFrameWidth) {
1305 ?
d->windowFrameMargins->top() : 0);
1354 d->layout->widgetEvent(
event);
1357 switch (
event->type()) {
1374 d->updateFont(
d->font);
1419 d->ensureWindowData();
1420 if (
d->hasDecoration() &&
d->windowData->grabbedSection !=
Qt::NoSection)
1426 if (
d->hasDecoration()) {
1453 switch (
event->type()) {
1458 d->layout->invalidate();
1468 d->resolveFont(
d->inheritedFontResolveMask);
1469 d->resolvePalette(
d->inheritedPaletteResolveMask);
1526 if (
d->scene->focusNextPrevChild(
next))
1726 return d->windowFlags;
1731 if (
d->windowFlags == wFlags)
1735 d->adjustWindowFlags(&wFlags);
1736 d->windowFlags = wFlags;
1737 if (!
d->setWindowFrameMargins)
1743 if (
d->scene &&
isVisible() && wasPopup != isPopup) {
1746 d->scene->d_func()->removePopup(
this);
1748 d->scene->d_func()->addPopup(
this);
1751 if (
d->scene &&
d->scene->d_func()->allItemsIgnoreHoverEvents &&
d->hasDecoration()) {
1752 d->scene->d_func()->allItemsIgnoreHoverEvents =
false;
1753 d->scene->d_func()->enableMouseTrackingOnViews();
1784 d->ensureWindowData();
1785 d->windowData->windowTitle =
title;
1790 return d->windowData ?
d->windowData->windowTitle :
QString();
1816 return d->focusPolicy;
1839 if (
d->subFocusItem &&
d->subFocusItem->d_ptr->isWidget)
1844#ifndef QT_NO_SHORTCUT
1990 qWarning(
"QWidget::insertAction: Attempt to insert null action");
1995 int index =
d->actions.indexOf(action);
1997 d->actions.removeAt(
index);
1999 int pos =
d->actions.indexOf(before);
2002 pos =
d->actions.size();
2004 d->actions.insert(
pos, action);
2049 if (
d->actions.removeAll(action)) {
2096 if (!
first && !second) {
2097 qWarning(
"QGraphicsWidget::setTabOrder(0, 0) is undefined");
2101 qWarning(
"QGraphicsWidget::setTabOrder: scenes %p and %p are different",
2107 qWarning(
"QGraphicsWidget::setTabOrder: assigning tab order from/to the"
2108 " scene requires the item to be in a scene.");
2127 if (firstFocusNext == second) {
2135 firstFocusNext->d_func()->focusPrev = second;
2136 first->d_func()->focusNext = second;
2137 second->d_func()->focusNext = firstFocusNext;
2138 second->d_func()->focusPrev =
first;
2139 secondFocusPrev->d_func()->focusNext = secondFocusNext;
2140 secondFocusNext->d_func()->focusPrev = secondFocusPrev;
2145 Q_ASSERT(second->d_func()->focusNext->d_func()->focusPrev == second);
2146 Q_ASSERT(second->d_func()->focusPrev->d_func()->focusNext == second);
2223 const bool embeddedWidgetFillsOwnBackground =
proxy &&
proxy->widget();
2235 bar.QStyleOption::operator=(*option);
2236 d->initStyleOptionTitleBar(&bar);
2237 d->ensureWindowData();
2248 if (pixmapSize.
width() <= 0 || pixmapSize.
height() <= 0)
2265 if (embeddedWidgetFillsOwnBackground) {
2271 windowFrameBackground.
addRect(
rect().translated(-styleOrigin).adjusted(0.5, 0.5, -0.5, -0.5));
2279 int height = (int)
d->titleBarHeight(bar);
2282 bar.
rect.
adjust(frameWidth, frameWidth, -frameWidth, 0);
2292 frameOptions.QStyleOption::operator=(*option);
2359void QGraphicsWidget::dumpFocusChain()
2361 qDebug(
"=========== Dumping focus chain ==============");
2367 qWarning(
"Found a focus chain that is not circular, (next == 0)");
2372 qWarning(
"Already visited this node. However, I expected to dump until I found myself.");
2377 }
while (
next !=
this);
2383#include "moc_qgraphicswidget.cpp"
The QActionEvent class provides an event that is generated when a QAction is added,...
QObjectList associatedObjects
The QAction class provides an abstraction for user commands that can be added to different user inter...
static QStyle * style()
Returns the application's style object.
static QFont font()
Returns the default application font.
The QCloseEvent class contains parameters that describe a close event.
static bool sendEvent(QObject *receiver, QEvent *event)
Sends event event directly to receiver receiver, using the notify() function.
static void postEvent(QObject *receiver, QEvent *event, int priority=Qt::NormalEventPriority)
@ GraphicsSceneMouseRelease
@ GraphicsSceneMousePress
@ GraphicsSceneHoverLeave
@ GraphicsSceneMouseDoubleClick
@ GraphicsSceneHoverEnter
The QFocusEvent class contains event parameters for widget focus events.
\reentrant \inmodule QtGui
QFont resolve(const QFont &) const
Returns a new QFont that has attributes copied from other that have not been previously set on this f...
void setResolveMask(uint mask)
The QGraphicsItem class is the base class for all graphical items in a QGraphicsScene.
virtual bool contains(const QPointF &point) const
Returns true if this item contains point, which is in local coordinates; otherwise,...
GraphicsItemChange
This enum describes the state changes that are notified by QGraphicsItem::itemChange().
friend class QGraphicsWidget
void update(const QRectF &rect=QRectF())
Schedules a redraw of the area covered by rect in this item.
QGraphicsWidget * parentWidget() const
virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value)
This virtual function is called by QGraphicsItem to notify custom items that some part of the item's ...
void clearFocus()
Takes keyboard input focus from the item.
QGraphicsScene * scene() const
Returns the current scene for the item, or \nullptr if the item is not stored in a scene.
QGraphicsWidget * window() const
bool isEnabled() const
Returns true if the item is enabled; otherwise, false is returned.
bool acceptHoverEvents() const
bool hasFocus() const
Returns true if this item is active, and it or its \l{focusProxy()}{focus proxy} has keyboard input f...
bool isUnderMouse() const
void prepareGeometryChange()
Prepares the item for a geometry change.
void setFlag(GraphicsItemFlag flag, bool enabled=true)
If enabled is true, the item flag flag is enabled; otherwise, it is disabled.
virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
This event handler, for event event, can be reimplemented to receive hover leave events for this item...
QGraphicsItem * parentItem() const
Returns a pointer to this item's parent item.
bool isVisible() const
Returns true if the item is visible; otherwise, false is returned.
void hide()
Hides the item (items are visible by default).
void setFocus(Qt::FocusReason focusReason=Qt::OtherFocusReason)
Gives keyboard input focus to this item.
virtual bool sceneEvent(QEvent *event)
This virtual function receives events to this item.
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
Returns the effective size hint for this QGraphicsLayoutItem.
QScopedPointer< QGraphicsLayoutItemPrivate > d_ptr
virtual void updateGeometry()
This virtual function discards any cached size hint information.
QRectF geometry() const
Returns the item's geometry (e.g., position and size) as a QRectF.
QGraphicsLayoutItem * parentLayoutItem() const
Returns the parent of this QGraphicsLayoutItem, or \nullptr if there is no parent,...
void setParentLayoutItem(QGraphicsLayoutItem *parent)
Sets the parent of this QGraphicsLayoutItem to parent.
virtual void setGeometry(const QRectF &rect)
This virtual function sets the geometry of the QGraphicsLayoutItem to rect, which is in parent coordi...
The QGraphicsLayout class provides the base class for all layouts in Graphics View.
bool isActivated() const
Returns true if the layout is currently being activated; otherwise, returns false.
virtual void invalidate()
Clears any cached geometry and size hint information in the layout, and posts a \l{QEvent::LayoutRequ...
static bool instantInvalidatePropagation()
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 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)
The QGraphicsScene class provides a surface for managing a large number of 2D graphical items.
static QGuiApplicationPrivate * instance()
bool remove(const Key &key)
Removes the item that has the key from the hash.
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.
bool isEmpty() const
Returns true if the key sequence is empty; otherwise returns false.
qsizetype size() const noexcept
const_reference at(qsizetype i) const noexcept
qsizetype removeAll(const AT &t)
void append(parameter_type t)
constexpr bool isNull() const noexcept
Returns true if all margins are very close to 0; otherwise returns false.
QString objectName
the name of this object
virtual bool event(QEvent *event)
This virtual function receives events to an object and should return true if the event e was recogniz...
void deleteLater()
\threadsafe
void addRect(const QRectF &rect)
Adds the given rectangle to this path as a closed subpath.
The QPainter class performs low-level painting on widgets and other paint devices.
void setClipRect(const QRectF &, Qt::ClipOperation op=Qt::ReplaceClip)
Enables clipping, and sets the clip region to the given rectangle using the given clip operation.
void restore()
Restores the current painter state (pops a saved state off the stack).
void save()
Saves the current painter state (pushes the state onto a stack).
void setFont(const QFont &f)
Sets the painter's font to the given font.
void drawPixmap(const QRectF &targetRect, const QPixmap &pixmap, const QRectF &sourceRect)
Draws the rectangular portion source of the given pixmap into the given target in the paint device.
void fillPath(const QPainterPath &path, const QBrush &brush)
Fills the given path using the given brush.
void translate(const QPointF &offset)
Translates the coordinate system by the given offset; i.e.
void fillRect(const QRectF &, const QBrush &)
Fills the given rectangle with the brush specified.
void setClipRegion(const QRegion &, Qt::ClipOperation op=Qt::ReplaceClip)
Sets the clip region to the given region using the specified clip operation.
The QPalette class contains color groups for each widget state.
void setCurrentColorGroup(ColorGroup cg)
Set the palette's current color group to cg.
ResolveMask resolveMask() const
QPalette resolve(const QPalette &other) const
Returns a new QPalette that is a union of this instance and other.
Returns a copy of the pixmap that is transformed using the given transformation transform and transfo...
\inmodule QtCore\reentrant
constexpr qreal x() const noexcept
Returns the x coordinate of this point.
constexpr qreal y() const noexcept
Returns the y coordinate of this point.
\inmodule QtCore\reentrant
\inmodule QtCore\reentrant
constexpr void moveTopLeft(const QPointF &p) noexcept
Moves the rectangle, leaving the top-left corner at the given position.
constexpr QRectF adjusted(qreal x1, qreal y1, qreal x2, qreal y2) const noexcept
Returns a new rectangle with dx1, dy1, dx2 and dy2 added respectively to the existing coordinates of ...
constexpr void setSize(const QSizeF &s) noexcept
Sets the size of the rectangle to the given finite size.
constexpr QPointF topLeft() const noexcept
Returns the position of the rectangle's top-left corner.
constexpr QSizeF size() const noexcept
Returns the size of the rectangle.
constexpr QRect toRect() const noexcept
Returns a QRect based on the values of this rectangle.
\inmodule QtCore\reentrant
constexpr void adjust(int x1, int y1, int x2, int y2) noexcept
Adds dx1, dy1, dx2 and dy2 respectively to the existing coordinates of the rectangle.
bool contains(const QRect &r, bool proper=false) const noexcept
This is an overloaded member function, provided for convenience. It differs from the above function o...
constexpr void setHeight(int h) noexcept
Sets the height of the rectangle to the given height.
T * data() const noexcept
Returns the value of the pointer referenced by this object.
bool contains(const T &value) const
The QShowEvent class provides an event that is sent when a widget is shown.
constexpr bool isValid() const noexcept
Returns true if both the width and height are equal to or greater than 0; otherwise returns false.
constexpr qreal width() const noexcept
Returns the width.
constexpr qreal height() const noexcept
Returns the height.
constexpr int height() const noexcept
Returns the height.
constexpr int width() const noexcept
Returns the width.
\macro QT_RESTRICTED_CAST_FROM_ASCII
static QString fromLatin1(QByteArrayView ba)
This is an overloaded member function, provided for convenience. It differs from the above function o...
QString arg(qlonglong a, int fieldwidth=0, int base=10, QChar fillChar=u' ') const
static QString number(int, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
The QStyleHintReturnMask class provides style hints that return a QRegion.
\variable QStyleOptionFocusRect::backgroundColor
The QStyleOptionGraphicsItem class is used to describe the parameters needed to draw a QGraphicsItem.
\variable QStyleOptionToolBox::selectedPosition
The QStyleOption class stores the parameters used by QStyle functions.
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
Draws the given control using the provided painter with the style options specified by option.
virtual int styleHint(StyleHint stylehint, const QStyleOption *opt=nullptr, const QWidget *widget=nullptr, QStyleHintReturn *returnData=nullptr) const =0
Returns an integer representing the specified style hint for the given widget described by the provid...
@ PM_MdiSubWindowFrameWidth
virtual int pixelMetric(PixelMetric metric, const QStyleOption *option=nullptr, const QWidget *widget=nullptr) const =0
Returns the value of the given pixel metric.
virtual void drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPainter *p, const QWidget *w=nullptr) const =0
Draws the given primitive element with the provided painter using the style options specified by opti...
Combined button and popup list for selecting options.
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
EGLOutputLayerEXT EGLint attribute
#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 GLsizei GLsizei GLenum GLenum GLsizei void * data
GLint GLint GLint GLint GLint GLint GLint GLbitfield mask
GLsizei const GLchar *const * path
QScopeGuard< typename std::decay< F >::type > qScopeGuard(F &&f)
[qScopeGuard]
#define qPrintable(string)
static void fillBackground(QPainter *p, const QRectF &rect, QBrush brush, const QPointF &origin, const QRectF &gradientRect=QRectF())
const char className[16]
[1]
obj metaObject() -> className()
app setAttribute(Qt::AA_DontShowIconsInMenus)
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent