Qt 4.8
Public Types | Public Functions | Public Variables | List of all members
QGraphicsProxyWidgetPrivate Class Reference

#include <qgraphicsproxywidget_p.h>

Inheritance diagram for QGraphicsProxyWidgetPrivate:
QGraphicsWidgetPrivate QGraphicsItemPrivate

Public Types

enum  ChangeMode { NoMode, ProxyToWidgetMode, WidgetToProxyMode }
 
- Public Types inherited from QGraphicsWidgetPrivate
enum  { Left, Top, Right, Bottom }
 
- Public Types inherited from QGraphicsItemPrivate
enum  AncestorFlag {
  NoFlag = 0, AncestorHandlesChildEvents = 0x1, AncestorClipsChildren = 0x2, AncestorIgnoresTransformations = 0x4,
  AncestorFiltersChildEvents = 0x8
}
 
enum  Extra {
  ExtraToolTip, ExtraCursor, ExtraCacheData, ExtraMaxDeviceCoordCacheSize,
  ExtraBoundingRegionGranularity
}
 
enum  InvalidateReason { OpacityChanged }
 

Public Functions

void _q_removeWidgetSlot ()
 
void embedSubWindow (QWidget *)
 Embeds subWin as a subwindow of this proxy widget. More...
 
QWidgetfindFocusChild (QWidget *child, bool next) const
 
void init ()
 
QVariant inputMethodQueryHelper (Qt::InputMethodQuery query) const
 Reimplemented from QGraphicsItemPrivate. More...
 
bool isProxyWidget () const
 
QPointF mapToReceiver (const QPointF &pos, const QWidget *receiver) const
 
 QGraphicsProxyWidgetPrivate ()
 
void removeSubFocusHelper (QWidget *widget, Qt::FocusReason reason)
 
void sendWidgetKeyEvent (QKeyEvent *event)
 
void sendWidgetMouseEvent (QGraphicsSceneMouseEvent *event)
 
void sendWidgetMouseEvent (QGraphicsSceneHoverEvent *event)
 
void setWidget_helper (QWidget *widget, bool autoShow)
 
void unembedSubWindow (QWidget *)
 Removes ("unembeds") subWin and deletes the proxy holder item. More...
 
void updateProxyGeometryFromWidget ()
 
void updateProxyInputMethodAcceptanceFromWidget ()
 
void updateWidgetGeometryFromProxy ()
 
- Public Functions inherited from QGraphicsWidgetPrivate
void _q_relayout ()
 
void adjustWindowFlags (Qt::WindowFlags *wFlags)
 
int attributeToBitIndex (Qt::WidgetAttribute att) const
 
void ensureMargins () const
 Ensures that margins is allocated. More...
 
void ensureWindowData ()
 Ensures that windowData is allocated. More...
 
void ensureWindowFrameMargins () const
 Ensures that windowFrameMargins is allocated. More...
 
void fixFocusChainBeforeReparenting (QGraphicsWidget *newParent, QGraphicsScene *oldScene, QGraphicsScene *newScene=0)
 
bool hasDecoration () const
 
qreal height () const
 
void init (QGraphicsItem *parentItem, Qt::WindowFlags wFlags)
 
void initStyleOptionTitleBar (QStyleOptionTitleBar *option)
 
QFont naturalWidgetFont () const
 
QPalette naturalWidgetPalette () const
 
 QGraphicsWidgetPrivate ()
 
void resetHeight ()
 
void resetWidth ()
 
void resolveFont (uint inheritedMask)
 
void resolveLayoutDirection ()
 
void resolvePalette (uint inheritedMask)
 
void setAttribute (Qt::WidgetAttribute att, bool value)
 
void setFont_helper (const QFont &font)
 
void setGeometryFromSetPos ()
 
void setHeight (qreal)
 
void setLayout_helper (QGraphicsLayout *l)
 
void setLayoutDirection_helper (Qt::LayoutDirection direction)
 
void setPalette_helper (const QPalette &palette)
 
void setWidth (qreal)
 
bool testAttribute (Qt::WidgetAttribute att) const
 
qreal titleBarHeight (const QStyleOptionTitleBar &options) const
 
void updateFont (const QFont &font)
 
void updatePalette (const QPalette &palette)
 
qreal width () const
 
void windowFrameHoverLeaveEvent (QGraphicsSceneHoverEvent *event)
 
void windowFrameHoverMoveEvent (QGraphicsSceneHoverEvent *event)
 
void windowFrameMouseMoveEvent (QGraphicsSceneMouseEvent *event)
 
void windowFrameMousePressEvent (QGraphicsSceneMouseEvent *event)
 
void windowFrameMouseReleaseEvent (QGraphicsSceneMouseEvent *event)
 
virtual ~QGraphicsWidgetPrivate ()
 
- Public Functions inherited from QGraphicsItemPrivate
void addChild (QGraphicsItem *child)
 QGraphicsScenePrivate::registerTopLevelItem(). More...
 
void appendGraphicsTransform (QGraphicsTransform *t)
 
qreal calcEffectiveOpacity () const
 
void childrenBoundingRectHelper (QTransform *x, QRectF *rect, QGraphicsItem *topMostEffectItem)
 Returns the bounding rect of this item's children (excluding itself). More...
 
bool childrenClippedToShape () const
 
bool childrenCombineOpacity () const
 
QDeclarativeListProperty< QGraphicsObjectchildrenList ()
 Returns a list of this item's children. More...
 
void clearFocusHelper (bool giveFocusToParent)
 
void clearSubFocus (QGraphicsItem *rootItem=0, QGraphicsItem *stopItem=0)
 
qreal combineOpacityFromParent (qreal parentOpacity) const
 
void combineTransformFromParent (QTransform *x, const QTransform *viewTransform=0) const
 Combines this item's position and transform onto transform. More...
 
void combineTransformToParent (QTransform *x, const QTransform *viewTransform=0) const
 Combines this item's position and transform onto transform. More...
 
int depth () const
 
bool discardUpdateRequest (bool ignoreVisibleBit=false, bool ignoreDirtyBit=false, bool ignoreOpacity=false) const
 Returns true if we can discard an update request; otherwise false. More...
 
QRectF effectiveBoundingRect (QGraphicsItem *topMostEffectItem=0) const
 Returns the effective bounding rect of the item. More...
 
QRectF effectiveBoundingRect (const QRectF &rect) const
 Returns the effective bounding rect of the given item space rect. More...
 
qreal effectiveOpacity () const
 
void ensureSceneTransform ()
 
void ensureSceneTransformRecursive (QGraphicsItem **topMostDirtyItem)
 
void ensureSequentialSiblingIndex ()
 Ensures that the list of children is sorted by insertion order, and that the siblingIndexes are packed (no gaps), and start at 0. More...
 
void ensureSortedChildren ()
 
QVariant extra (Extra type) const
 
QGraphicsItemCacheextraItemCache () const
 
virtual void focusScopeItemChange (bool isSubFocusItem)
 Subclasses can reimplement this function to be notified when an item becomes a focusScopeItem (or is no longer a focusScopeItem). More...
 
QPointF genericMapFromScene (const QPointF &pos, const QWidget *viewport) const
 Maps the point pos from scene to item coordinates. More...
 
bool hasTranslateOnlySceneTransform ()
 
void initStyleOption (QStyleOptionGraphicsItem *option, const QTransform &worldTransform, const QRegion &exposedRegion, bool allItems=false) const
 
void invalidateChildGraphicsEffectsRecursively (InvalidateReason reason)
 
void invalidateChildrenSceneTransform ()
 
void invalidateDepthRecursively ()
 
void invalidateParentGraphicsEffectsRecursively ()
 
bool isFullyTransparent () const
 
bool isInvisible () const
 
bool isOpacityNull () const
 
bool itemIsUntransformable () const
 
void markParentDirty (bool updateBoundingRect=false)
 
QGraphicsItemCachemaybeExtraItemCache () const
 
void prependGraphicsTransform (QGraphicsTransform *t)
 
 QGraphicsItemPrivate ()
 
void remapItemPos (QEvent *event, QGraphicsItem *item)
 Maps any item pos properties of event to item's coordinate system. More...
 
void removeChild (QGraphicsItem *child)
 QGraphicsScenePrivate::unregisterTopLevelItem(). More...
 
void removeExtraItemCache ()
 
void resetFocusProxy ()
 Sets the focusProxy pointer to 0 for all items that have this item as their focusProxy. More...
 
void resolveDepth ()
 Resolves the stacking depth of this object and all its ancestors. More...
 
QRectF sceneEffectiveBoundingRect () const
 Returns the effective bounding rect of this item in scene coordinates, by combining sceneTransform() with boundingRect(), taking into account the effect that the item might have. More...
 
void sendScenePosChange ()
 
void setEnabledHelper (bool newEnabled, bool explicitly, bool update=true)
 Sets this item's visibility to newEnabled. More...
 
void setExtra (Extra type, const QVariant &value)
 
void setFocusHelper (Qt::FocusReason focusReason, bool climb, bool focusFromHide)
 
void setIsMemberOfGroup (bool enabled)
 Propagates item group membership. More...
 
void setParentItemHelper (QGraphicsItem *parent, const QVariant *newParentVariant, const QVariant *thisPointerVariant)
 Make sure not to trigger any pure virtual function calls (e. More...
 
virtual void setPosHelper (const QPointF &pos)
 Sets the position pos. More...
 
void setSubFocus (QGraphicsItem *rootItem=0, QGraphicsItem *stopItem=0)
 
void setTransformHelper (const QTransform &transform)
 Sets the transform transform. More...
 
void setVisibleHelper (bool newVisible, bool explicitly, bool update=true)
 Sets this item's visibility to newVisible. More...
 
virtual void siblingOrderChange ()
 Subclasses can reimplement this function to be notified when its siblingIndex order is changed. More...
 
virtual void subFocusItemChange ()
 Subclasses can reimplement this function to be notified when subFocusItem changes. More...
 
virtual void transformChanged ()
 
QTransform transformToParent () const
 
void unsetExtra (Extra type)
 
void updateAncestorFlag (QGraphicsItem::GraphicsItemFlag childFlag, AncestorFlag flag=NoFlag, bool enabled=false, bool root=true)
 Propagates the ancestor flag flag with value enabled to all this item's children. More...
 
void updateAncestorFlags ()
 
void updateChildWithGraphicsEffectFlagRecursively ()
 
void updatePaintedViewBoundingRects (bool updateChildren)
 
virtual void updateSceneTransformFromParent ()
 
virtual ~QGraphicsItemPrivate ()
 

Public Variables

QWidgetdragDropWidget
 
QPointer< QWidgetembeddedMouseGrabber
 
quint32 enabledChangeMode: 2
 
quint32 focusFromWidgetToProxy: 1
 
Qt::DropAction lastDropAction
 
QPointer< QWidgetlastWidgetUnderMouse
 
quint32 paletteChangeMode: 2
 
quint32 posChangeMode: 2
 
quint32 proxyIsGivingFocus: 1
 
quint32 sizeChangeMode: 2
 
quint32 styleChangeMode: 2
 
quint32 tooltipChangeMode: 2
 
quint32 visibleChangeMode: 2
 
QPointer< QWidgetwidget
 
- Public Variables inherited from QGraphicsWidgetPrivate
QList< QAction * > actions
 
quint32 attributes: 10
 
quint32 autoFillBackground: 1
 
QGraphicsWidgetfocusNext
 
Qt::FocusPolicy focusPolicy
 
QGraphicsWidgetfocusPrev
 
QFont font
 
uint inheritedFontResolveMask
 
uint inheritedPaletteResolveMask
 
quint32 inSetGeometry: 1
 
quint32 inSetPos: 1
 
QGraphicsLayoutlayout
 
qrealmargins
 
quint32 padding: 2
 
QPalette palette
 
quint32 polished: 1
 
quint32 refCountInvokeRelayout: 16
 
bool setWindowFrameMargins
 
struct QGraphicsWidgetPrivate::WindowDatawindowData
 
Qt::WindowFlags windowFlags
 
qrealwindowFrameMargins
 
- Public Variables inherited from QGraphicsItemPrivate
quint32 acceptDrops: 1
 
quint32 acceptedMouseButtons: 5
 
quint32 acceptedTouchBeginEvent: 1
 
quint32 acceptsHover: 1
 
quint32 acceptTouchEvents: 1
 
quint32 allChildrenDirty: 1
 
quint32 ancestorFlags: 4
 
quint32 cacheMode: 2
 
QList< QGraphicsItem * > children
 
QRectF childrenBoundingRect
 
quint32 dirty: 1
 
quint32 dirtyChildren: 1
 
quint32 dirtyChildrenBoundingRect: 1
 
quint32 dirtySceneTransform: 1
 
quint32 enabled: 1
 
quint32 explicitActivate: 1
 
quint32 explicitlyDisabled: 1
 
quint32 explicitlyHidden: 1
 
QList< ExtraStructextras
 
quint32 filtersDescendantEvents: 1
 
quint32 flags: 19
 
QGraphicsItemfocusProxy
 
QList< QGraphicsItem ** > focusProxyRefs
 
QGraphicsItemfocusScopeItem
 
quint32 fullUpdatePending: 1
 
quint32 geometryChanged: 1
 
QMap< Qt::GestureType, Qt::GestureFlags > gestureContext
 
int globalStackingOrder
 
QGraphicsEffectgraphicsEffect
 
quint32 handlesChildEvents: 1
 
quint32 hasBoundingRegionGranularity: 1
 
quint32 hasCursor: 1
 
quint32 holesInSiblingIndex: 1
 
quint32 ignoreOpacity: 1
 
quint32 ignoreVisible: 1
 
Qt::InputMethodHints imHints
 
quint32 inDestructor: 1
 
int index
 
quint32 inSetPosHelper: 1
 
quint32 isDeclarativeItem: 1
 
quint32 isMemberOfGroup: 1
 
quint32 isObject: 1
 
quint32 isWidget: 1
 
int itemDepth
 
quint32 itemDiscovered: 1
 
quint32 localCollisionHack: 1
 
quint32 mayHaveChildWithGraphicsEffect: 1
 
quint32 mouseSetsFocus: 1
 
quint32 needSortChildren: 1
 
QRectF needsRepaint
 
quint32 notifyBoundingRectChanged: 1
 
quint32 notifyInvalidated: 1
 
qreal opacity
 
quint32 padding: 21
 
QMap< QWidget *, QRectpaintedViewBoundingRects
 
quint32 paintedViewBoundingRectsNeedRepaint: 1
 
QGraphicsItem::PanelModality panelModality
 
QGraphicsItemparent
 
quint32 pendingPolish: 1
 
QPointF pos
 
QGraphicsItemq_ptr
 
QGraphicsScenescene
 
quint32 scenePosDescendants: 1
 
QTransform sceneTransform
 
quint32 sceneTransformTranslateOnly: 1
 
quint32 selected: 1
 
quint32 sendParentChangeNotification: 1
 
quint32 sequentialOrdering: 1
 
int siblingIndex
 
QGraphicsItemsubFocusItem
 
TransformDatatransformData
 
quint32 updateDueToGraphicsEffect: 1
 
quint32 visible: 1
 
quint32 wantsActive: 1
 
qreal z
 

Additional Inherited Members

- Static Public Functions inherited from QGraphicsItemPrivate
static void children_append (QDeclarativeListProperty< QGraphicsObject > *list, QGraphicsObject *item)
 
static QGraphicsObjectchildren_at (QDeclarativeListProperty< QGraphicsObject > *list, int)
 
static void children_clear (QDeclarativeListProperty< QGraphicsObject > *list)
 
static int children_count (QDeclarativeListProperty< QGraphicsObject > *list)
 
static const QGraphicsItemPrivateget (const QGraphicsItem *item)
 
static QGraphicsItemPrivateget (QGraphicsItem *item)
 
static bool insertionOrder (QGraphicsItem *a, QGraphicsItem *b)
 
static bool isOpacityNull (qreal opacity)
 
static bool movableAncestorIsSelected (const QGraphicsItem *item)
 

Detailed Description

Definition at line 63 of file qgraphicsproxywidget_p.h.

Enumerations

◆ ChangeMode

Constructors and Destructors

◆ QGraphicsProxyWidgetPrivate()

QGraphicsProxyWidgetPrivate::QGraphicsProxyWidgetPrivate ( )
inline

Functions

◆ _q_removeWidgetSlot()

void QGraphicsProxyWidgetPrivate::_q_removeWidgetSlot ( )
Warning
This function is not part of the public interface.

Definition at line 413 of file qgraphicsproxywidget.cpp.

Referenced by QGraphicsProxyWidgetPrivate().

414 {
416  widget = 0;
417  delete q;
418 }
#define Q_Q(Class)
Definition: qglobal.h:2483
The QGraphicsProxyWidget class provides a proxy layer for embedding a QWidget in a QGraphicsScene...

◆ embedSubWindow()

void QGraphicsProxyWidgetPrivate::embedSubWindow ( QWidget subWin)

Embeds subWin as a subwindow of this proxy widget.

Warning
This function is not part of the public interface.

subWin must be a top-level widget and a descendant of the widget managed by this proxy. A separate subproxy will be created as a child of this proxy widget to manage subWin.

Definition at line 487 of file qgraphicsproxywidget.cpp.

Referenced by QGraphicsProxyWidgetPrivate().

488 {
489  QWExtra *extra;
490  if (!((extra = subWin->d_func()->extra) && extra->proxyWidget)) {
491  QGraphicsProxyWidget *subProxy = new QGraphicsProxyWidget(q_func(), subWin->windowFlags());
492  subProxy->d_func()->setWidget_helper(subWin, false);
493  }
494 }
QGraphicsProxyWidget * proxyWidget
Definition: qwidget_p.h:251
QVariant extra(Extra type) const
The QGraphicsProxyWidget class provides a proxy layer for embedding a QWidget in a QGraphicsScene...
Qt::WindowFlags windowFlags() const
Window flags are a combination of a type (e.
Definition: qwidget.h:939

◆ findFocusChild()

QWidget * QGraphicsProxyWidgetPrivate::findFocusChild ( QWidget child,
bool  next 
) const
Warning
This function is not part of the public interface. Some of the logic is shared with QApplicationPrivate::focusNextPrevChild_helper

Definition at line 381 of file qgraphicsproxywidget.cpp.

Referenced by QGraphicsProxyWidgetPrivate().

382 {
383  if (!widget)
384  return 0;
385 
386  // Run around the focus chain until we find a widget that can take tab focus.
387  if (!child) {
388  child = next ? (QWidget *)widget : widget->d_func()->focus_prev;
389  } else {
390  child = next ? child->d_func()->focus_next : child->d_func()->focus_prev;
391  if ((next && child == widget) || (!next && child == widget->d_func()->focus_prev)) {
392  return 0;
393  }
394  }
395 
396  QWidget *oldChild = child;
398  do {
399  if (child->isEnabled()
400  && child->isVisibleTo(widget)
401  && ((child->focusPolicy() & focus_flag) == focus_flag)
402  && !(child->d_func()->extra && child->d_func()->extra->focus_proxy)) {
403  return child;
404  }
405  child = next ? child->d_func()->focus_next : child->d_func()->focus_prev;
406  } while (child != oldChild && !(next && child == widget) && !(!next && child == widget->d_func()->focus_prev));
407  return 0;
408 }
bool isVisibleTo(QWidget *) const
Returns true if this widget would become visible if ancestor is shown; otherwise returns false...
Definition: qwidget.cpp:8371
Qt::FocusPolicy focusPolicy
the way the widget accepts keyboard focus
Definition: qwidget.h:187
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
unsigned int uint
Definition: qglobal.h:996
bool isEnabled() const
Definition: qwidget.h:948
Q_GUI_EXPORT bool qt_tab_all_widgets

◆ init()

void QGraphicsProxyWidgetPrivate::init ( )
Warning
This function is not part of the public interface.

Definition at line 195 of file qgraphicsproxywidget.cpp.

Referenced by QGraphicsProxyWidgetPrivate().

196 {
198  q->setFocusPolicy(Qt::WheelFocus);
199  q->setAcceptDrops(true);
200 }
#define Q_Q(Class)
Definition: qglobal.h:2483
The QGraphicsProxyWidget class provides a proxy layer for embedding a QWidget in a QGraphicsScene...

◆ inputMethodQueryHelper()

QVariant QGraphicsProxyWidgetPrivate::inputMethodQueryHelper ( Qt::InputMethodQuery  query) const
virtual

Reimplemented from QGraphicsItemPrivate.

Warning
This function is not part of the public interface.

Qt 5: Move impl to

reimplementation QGraphicsProxyWidget::inputMethodQuery().

Reimplemented from QGraphicsItemPrivate.

Definition at line 347 of file qgraphicsproxywidget.cpp.

Referenced by QGraphicsProxyWidgetPrivate().

348 {
349  Q_Q(const QGraphicsProxyWidget);
350  if (!widget || !q->hasFocus())
351  return QVariant();
352 
353  QWidget *focusWidget = widget->focusWidget();
354  if (!focusWidget)
355  focusWidget = widget;
356  QVariant v = focusWidget->inputMethodQuery(query);
357  QPointF focusWidgetPos = q->subWidgetRect(focusWidget).topLeft();
358  switch (v.type()) {
359  case QVariant::RectF:
360  v = v.toRectF().translated(focusWidgetPos);
361  break;
362  case QVariant::PointF:
363  v = v.toPointF() + focusWidgetPos;
364  break;
365  case QVariant::Rect:
366  v = v.toRect().translated(focusWidgetPos.toPoint());
367  break;
368  case QVariant::Point:
369  v = v.toPoint() + focusWidgetPos.toPoint();
370  break;
371  default:
372  break;
373  }
374  return v;
375 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
QWidget * focusWidget() const
Returns the last child of this widget that setFocus had been called on.
Definition: qwidget.cpp:6863
QPointF toPointF() const
Returns the variant as a QPointF if the variant has type() Point or PointF ; otherwise returns a null...
Definition: qvariant.cpp:2509
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
QRect translated(int dx, int dy) const
Returns a copy of the rectangle that is translated dx along the x axis and dy along the y axis...
Definition: qrect.h:328
virtual QVariant inputMethodQuery(Qt::InputMethodQuery) const
This method is only relevant for input widgets.
Definition: qwidget.cpp:9683
bool hasFocus() const
Definition: qwidget.cpp:6583
QRectF toRectF() const
Returns the variant as a QRectF if the variant has type() Rect or RectF ; otherwise returns an invali...
Definition: qvariant.cpp:2463
#define Q_Q(Class)
Definition: qglobal.h:2483
The QGraphicsProxyWidget class provides a proxy layer for embedding a QWidget in a QGraphicsScene...
QRect toRect() const
Returns the variant as a QRect if the variant has type() Rect ; otherwise returns an invalid QRect...
Definition: qvariant.cpp:2416
QPoint toPoint() const
Rounds the coordinates of this point to the nearest integer, and returns a QPoint object with the rou...
Definition: qpoint.h:376
Type type() const
Returns the storage type of the value stored in the variant.
Definition: qvariant.cpp:1901
QRectF translated(qreal dx, qreal dy) const
Returns a copy of the rectangle that is translated dx along the x axis and dy along the y axis...
Definition: qrect.h:740
QPoint toPoint() const
Returns the variant as a QPoint if the variant has type() Point or PointF ; otherwise returns a null ...
Definition: qvariant.cpp:2400

◆ isProxyWidget()

bool QGraphicsProxyWidgetPrivate::isProxyWidget ( ) const
virtual
Warning
This function is not part of the public interface.

Tells us if it is a proxy widget

Reimplemented from QGraphicsItemPrivate.

Definition at line 522 of file qgraphicsproxywidget.cpp.

Referenced by QGraphicsProxyWidgetPrivate().

523 {
524  return true;
525 }

◆ mapToReceiver()

QPointF QGraphicsProxyWidgetPrivate::mapToReceiver ( const QPointF pos,
const QWidget receiver 
) const
Warning
This function is not part of the public interface.

Definition at line 530 of file qgraphicsproxywidget.cpp.

Referenced by sendWidgetMouseEvent().

531 {
532  QPointF p = pos;
533  // Map event position from us to the receiver, preserving its
534  // precision (don't use QWidget::mapFrom here).
535  while (receiver && receiver != widget) {
536  p -= QPointF(receiver->pos());
537  receiver = receiver->parentWidget();
538  }
539  return p;
540 }
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
QPoint pos
the position of the widget within its parent widget
Definition: qwidget.h:163

◆ removeSubFocusHelper()

void QGraphicsProxyWidgetPrivate::removeSubFocusHelper ( QWidget widget,
Qt::FocusReason  reason 
)
Warning
This function is not part of the public interface.

Definition at line 329 of file qgraphicsproxywidget.cpp.

Referenced by QGraphicsProxyWidgetPrivate().

330 {
332  QPointer<QWidget> widgetGuard = widget;
333  QApplication::sendEvent(widget, &event);
334  if (widgetGuard && event.isAccepted())
335  QApplication::sendEvent(widget->style(), &event);
336 }
EventRef event
QStyle * style() const
Definition: qwidget.cpp:2742
static bool sendEvent(QObject *receiver, QEvent *event)
Sends event event directly to receiver receiver, using the notify() function.
The QFocusEvent class contains event parameters for widget focus events.
Definition: qevent.h:275

◆ sendWidgetKeyEvent()

void QGraphicsProxyWidgetPrivate::sendWidgetKeyEvent ( QKeyEvent event)

Definition at line 307 of file qgraphicsproxywidget.cpp.

Referenced by QGraphicsProxyWidgetPrivate().

308 {
310  if (!event || !widget || !widget->isVisible())
311  return;
312 
313  QPointer<QWidget> receiver = widget->focusWidget();
314  if (!receiver)
315  receiver = widget;
316  Q_ASSERT(receiver);
317 
318  do {
319  bool res = QApplication::sendEvent(receiver, event);
320  if ((res && event->isAccepted()) || (q->isWindow() && receiver == widget))
321  break;
322  receiver = receiver->parentWidget();
323  } while (receiver);
324 }
QWidget * parentWidget() const
Returns the parent of this widget, or 0 if it does not have any parent widget.
Definition: qwidget.h:1035
QWidget * focusWidget() const
Returns the last child of this widget that setFocus had been called on.
Definition: qwidget.cpp:6863
bool isVisible() const
Definition: qwidget.h:1005
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
#define Q_Q(Class)
Definition: qglobal.h:2483
bool isAccepted() const
Definition: qcoreevent.h:307
static bool sendEvent(QObject *receiver, QEvent *event)
Sends event event directly to receiver receiver, using the notify() function.
The QGraphicsProxyWidget class provides a proxy layer for embedding a QWidget in a QGraphicsScene...

◆ sendWidgetMouseEvent() [1/2]

void QGraphicsProxyWidgetPrivate::sendWidgetMouseEvent ( QGraphicsSceneMouseEvent event)
Warning
This function is not part of the public interface.

Definition at line 220 of file qgraphicsproxywidget.cpp.

Referenced by QGraphicsProxyWidgetPrivate(), and sendWidgetMouseEvent().

221 {
222  if (!event || !widget || !widget->isVisible())
223  return;
225 
226  // Find widget position and receiver.
227  QPointF pos = event->pos();
228  QPointer<QWidget> alienWidget = widget->childAt(pos.toPoint());
229  QPointer<QWidget> receiver = alienWidget ? alienWidget : widget;
230 
232  return; //another proxywidget will handle the events
233 
234  // Translate QGraphicsSceneMouse events to QMouseEvents.
236  switch (event->type()) {
240  embeddedMouseGrabber = receiver;
241  else
242  receiver = embeddedMouseGrabber;
243  break;
247  receiver = embeddedMouseGrabber;
248  break;
252  embeddedMouseGrabber = receiver;
253  else
254  receiver = embeddedMouseGrabber;
255  break;
257  type = QEvent::MouseMove;
259  receiver = embeddedMouseGrabber;
260  break;
261  default:
262  Q_ASSERT_X(false, "QGraphicsProxyWidget", "internal error");
263  break;
264  }
265 
266  if (!lastWidgetUnderMouse) {
268  lastWidgetUnderMouse = receiver;
269  }
270 
271  // Map event position from us to the receiver
272  pos = mapToReceiver(pos, receiver);
273 
274  // Send mouse event.
276  receiver->mapToGlobal(pos.toPoint()), event->button(),
277  event->buttons(), event->modifiers());
278 
279  QWidget *embeddedMouseGrabberPtr = (QWidget *)embeddedMouseGrabber;
280  QApplicationPrivate::sendMouseEvent(receiver, mouseEvent, alienWidget, widget,
281  &embeddedMouseGrabberPtr, lastWidgetUnderMouse, event->spontaneous());
282  embeddedMouseGrabber = embeddedMouseGrabberPtr;
283 
284  // Handle enter/leave events when last button is released from mouse
285  // grabber child widget.
286  if (embeddedMouseGrabber && type == QEvent::MouseButtonRelease && !event->buttons()) {
288  if (q->rect().contains(event->pos()) && q->acceptsHoverEvents())
289  lastWidgetUnderMouse = alienWidget ? alienWidget : widget;
290  else // released on the frame our outside the item, or doesn't accept hover events.
292 
294  embeddedMouseGrabber = 0;
295 
296 #ifndef QT_NO_CURSOR
297  // ### Restore the cursor, don't override it.
299  q->unsetCursor();
300 #endif
301  }
302 
303  event->setAccepted(mouseEvent->isAccepted());
304  delete mouseEvent;
305 }
int type
Definition: qmetatype.cpp:239
static QMouseEvent * createExtendedMouseEvent(Type type, const QPointF &pos, const QPoint &globalPos, Qt::MouseButton button, Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers)
Definition: qevent.cpp:251
bool isVisible() const
Definition: qwidget.h:1005
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
Qt::MouseButton button() const
Returns the mouse button (if any) that caused the event.
#define Q_Q(Class)
Definition: qglobal.h:2483
QPointF mapToReceiver(const QPointF &pos, const QWidget *receiver) const
bool isAccepted() const
Definition: qcoreevent.h:307
QWidget * childAt(int x, int y) const
Returns the visible child widget at the position ({x}, {y}) in the widget&#39;s coordinate system...
Definition: qwidget.h:934
bool spontaneous() const
Returns true if the event originated outside the application (a system event); otherwise returns fals...
Definition: qcoreevent.h:304
The QGraphicsProxyWidget class provides a proxy layer for embedding a QWidget in a QGraphicsScene...
The QMouseEvent class contains parameters that describe a mouse event.
Definition: qevent.h:85
#define Q_ASSERT_X(cond, where, what)
Definition: qglobal.h:1837
Type
This enum type defines the valid event types in Qt.
Definition: qcoreevent.h:62
QPoint toPoint() const
Rounds the coordinates of this point to the nearest integer, and returns a QPoint object with the rou...
Definition: qpoint.h:376
static void mouseEvent(MouseAction action, QWidget *widget, Qt::MouseButton button, Qt::KeyboardModifiers stateKey, QPoint pos, int delay=-1)
Definition: qtestmouse.h:71
static void dispatchEnterLeave(QWidget *enter, QWidget *leave)
QPointF pos() const
Returns the mouse cursor position in item coordinates.
static QGraphicsProxyWidget * nearestGraphicsProxyWidget(const QWidget *origin)
Finds the nearest widget embedded in a graphics proxy widget along the chain formed by this widget an...
Definition: qwidget.cpp:6098
QPointer< QWidget > embeddedMouseGrabber
static bool sendMouseEvent(QWidget *receiver, QMouseEvent *event, QWidget *alienWidget, QWidget *native, QWidget **buttonDown, QPointer< QWidget > &lastMouseReceiver, bool spontaneous=true)
Type type() const
Returns the event type.
Definition: qcoreevent.h:303
QPointer< QWidget > lastWidgetUnderMouse
QPoint mapToGlobal(const QPoint &) const
Translates the widget coordinate pos to global screen coordinates.
Qt::MouseButtons buttons() const
Returns the combination of mouse buttons that were pressed at the time the event was sent...

◆ sendWidgetMouseEvent() [2/2]

void QGraphicsProxyWidgetPrivate::sendWidgetMouseEvent ( QGraphicsSceneHoverEvent event)
Warning
This function is not part of the public interface.

Definition at line 205 of file qgraphicsproxywidget.cpp.

206 {
208  mouseEvent.setPos(event->pos());
209  mouseEvent.setScreenPos(event->screenPos());
210  mouseEvent.setButton(Qt::NoButton);
211  mouseEvent.setButtons(0);
212  mouseEvent.setModifiers(event->modifiers());
214  event->setAccepted(mouseEvent.isAccepted());
215 }
QPoint screenPos() const
Returns the position of the mouse cursor in screen coordinates at the moment the hover event was sent...
The QGraphicsSceneMouseEvent class provides mouse events in the graphics view framework.
void sendWidgetMouseEvent(QGraphicsSceneMouseEvent *event)
Qt::KeyboardModifiers modifiers() const
Returns the keyboard modifiers at the moment the hover event was sent.
QPointF pos() const
Returns the position of the mouse cursor in item coordinates at the moment the hover event was sent...
static void mouseEvent(MouseAction action, QWidget *widget, Qt::MouseButton button, Qt::KeyboardModifiers stateKey, QPoint pos, int delay=-1)
Definition: qtestmouse.h:71

◆ setWidget_helper()

void QGraphicsProxyWidgetPrivate::setWidget_helper ( QWidget widget,
bool  autoShow 
)

Definition at line 603 of file qgraphicsproxywidget.cpp.

Referenced by QGraphicsProxyWidgetPrivate().

604 {
606  if (newWidget == widget)
607  return;
608  if (widget) {
609  QObject::disconnect(widget, SIGNAL(destroyed()), q, SLOT(_q_removeWidgetSlot()));
610  widget->removeEventFilter(q);
611  widget->setAttribute(Qt::WA_DontShowOnScreen, false);
612  widget->d_func()->extra->proxyWidget = 0;
615  widget->update();
616 
617  foreach (QGraphicsItem *child, q->childItems()) {
618  if (child->d_ptr->isProxyWidget()) {
619  QGraphicsProxyWidget *childProxy = static_cast<QGraphicsProxyWidget *>(child);
620  QWidget * parent = childProxy->widget();
621  while (parent->parentWidget() != 0) {
622  if (parent == widget)
623  break;
624  parent = parent->parentWidget();
625  }
626  if (!childProxy->widget() || parent != widget)
627  continue;
628  childProxy->setWidget(0);
629  delete childProxy;
630  }
631  }
632 
633  widget = 0;
634 #ifndef QT_NO_CURSOR
635  q->unsetCursor();
636 #endif
637  q->setAcceptHoverEvents(false);
638  if (!newWidget)
639  q->update();
640  }
641  if (!newWidget)
642  return;
643  if (!newWidget->isWindow()) {
644  QWExtra *extra = newWidget->parentWidget()->d_func()->extra;
645  if (!extra || !extra->proxyWidget) {
646  qWarning("QGraphicsProxyWidget::setWidget: cannot embed widget %p "
647  "which is not a toplevel widget, and is not a child of an embedded widget", newWidget);
648  return;
649  }
650  }
651 
652  // Register this proxy within the widget's private.
653  // ### This is a bit backdoorish
654  QWExtra *extra = newWidget->d_func()->extra;
655  if (!extra) {
656  newWidget->d_func()->createExtra();
657  extra = newWidget->d_func()->extra;
658  }
659  QGraphicsProxyWidget **proxyWidget = &extra->proxyWidget;
660  if (*proxyWidget) {
661  if (*proxyWidget != q) {
662  qWarning("QGraphicsProxyWidget::setWidget: cannot embed widget %p"
663  "; already embedded", newWidget);
664  }
665  return;
666  }
667  *proxyWidget = q;
668 
670  newWidget->ensurePolished();
671  // Do not wait for this widget to close before the app closes ###
672  // shouldn't this widget inherit the attribute?
673  newWidget->setAttribute(Qt::WA_QuitOnClose, false);
674  q->setAcceptHoverEvents(true);
675 
676  if (newWidget->testAttribute(Qt::WA_NoSystemBackground))
677  q->setAttribute(Qt::WA_NoSystemBackground);
678  if (newWidget->testAttribute(Qt::WA_OpaquePaintEvent))
679  q->setAttribute(Qt::WA_OpaquePaintEvent);
680 
681  widget = newWidget;
682 
683  // Changes only go from the widget to the proxy.
688 
689  if ((autoShow && !newWidget->testAttribute(Qt::WA_WState_ExplicitShowHide)) || !newWidget->testAttribute(Qt::WA_WState_Hidden)) {
690  newWidget->show();
691  }
692 
693  // Copy the state from the widget onto the proxy.
694 #ifndef QT_NO_CURSOR
695  if (newWidget->testAttribute(Qt::WA_SetCursor))
696  q->setCursor(widget->cursor());
697 #endif
698  q->setEnabled(newWidget->isEnabled());
699  q->setVisible(newWidget->isVisible());
700  q->setLayoutDirection(newWidget->layoutDirection());
701  if (newWidget->testAttribute(Qt::WA_SetStyle))
702  q->setStyle(widget->style());
703 
706 
707  if (!newWidget->testAttribute(Qt::WA_Resized))
708  newWidget->adjustSize();
709 
710  int left, top, right, bottom;
711  newWidget->getContentsMargins(&left, &top, &right, &bottom);
712  q->setContentsMargins(left, top, right, bottom);
713  q->setWindowTitle(newWidget->windowTitle());
714 
715  // size policies and constraints..
716  q->setSizePolicy(newWidget->sizePolicy());
717  QSize sz = newWidget->minimumSize();
718  q->setMinimumSize(sz.isNull() ? QSizeF() : QSizeF(sz));
719  sz = newWidget->maximumSize();
720  q->setMaximumSize(sz.isNull() ? QSizeF() : QSizeF(sz));
721 
723 
725 
726  // Hook up the event filter to keep the state up to date.
727  newWidget->installEventFilter(q);
728  QObject::connect(newWidget, SIGNAL(destroyed()), q, SLOT(_q_removeWidgetSlot()));
729 
730  // Changes no longer go only from the widget to the proxy.
735 }
QWidget * parentWidget() const
Returns the parent of this widget, or 0 if it does not have any parent widget.
Definition: qwidget.h:1035
QGraphicsItem * parent
QList< QGraphicsItem * > childItems() const
Returns a list of this item&#39;s children.
QScopedPointer< QGraphicsItemPrivate > d_ptr
void unsetCursor()
Definition: qwidget.cpp:5311
#define SLOT(a)
Definition: qobjectdefs.h:226
The QGraphicsItem class is the base class for all graphical items in a QGraphicsScene.
Definition: qgraphicsitem.h:89
void resolveFont(uint inheritedMask)
void removeEventFilter(QObject *)
Removes an event filter object obj from this object.
Definition: qobject.cpp:2099
void setWidget(QWidget *widget)
Embeds widget into this proxy widget.
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
The QSizeF class defines the size of a two-dimensional object using floating point precision...
Definition: qsize.h:202
Q_CORE_EXPORT QTextStream & right(QTextStream &s)
QStyle * style() const
Definition: qwidget.cpp:2742
#define Q_Q(Class)
Definition: qglobal.h:2483
void resolvePalette(uint inheritedMask)
void update()
Updates the widget unless updates are disabled or the widget is hidden.
Definition: qwidget.cpp:10883
QGraphicsProxyWidget * proxyWidget
Definition: qwidget_p.h:251
#define SIGNAL(a)
Definition: qobjectdefs.h:227
virtual bool isProxyWidget() const
static bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
Creates a connection of the given type from the signal in the sender object to the method in the rece...
Definition: qobject.cpp:2580
Q_CORE_EXPORT void qWarning(const char *,...)
QCursor cursor
the cursor shape for this widget
Definition: qwidget.h:183
QVariant extra(Extra type) const
void setAttribute(Qt::WidgetAttribute attribute, bool on=true)
If on is true, this function enables attribute; otherwise attribute is disabled.
The QGraphicsProxyWidget class provides a proxy layer for embedding a QWidget in a QGraphicsScene...
static bool disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *member)
Disconnects signal in object sender from method in object receiver.
Definition: qobject.cpp:2895
void setAttribute(Qt::WidgetAttribute, bool on=true)
Sets the attribute attribute on this widget if on is true; otherwise clears the attribute.
Definition: qwidget.cpp:11087
bool isNull() const
Returns true if both the width and height is 0; otherwise returns false.
Definition: qsize.h:117
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
Q_CORE_EXPORT QTextStream & left(QTextStream &s)
QWidget * widget() const
Returns a pointer to the embedded widget.

◆ unembedSubWindow()

void QGraphicsProxyWidgetPrivate::unembedSubWindow ( QWidget subWin)

Removes ("unembeds") subWin and deletes the proxy holder item.

Warning
This function is not part of the public interface.

This can happen when QWidget::setParent() reparents the embedded window out of "embedded space".

Definition at line 506 of file qgraphicsproxywidget.cpp.

Referenced by QGraphicsProxyWidgetPrivate().

507 {
508  foreach (QGraphicsItem *child, children) {
509  if (child->isWidget()) {
510  if (QGraphicsProxyWidget *proxy = qobject_cast<QGraphicsProxyWidget *>(static_cast<QGraphicsWidget *>(child))) {
511  if (proxy->widget() == subWin) {
512  proxy->setWidget(0);
513  scene->removeItem(proxy);
514  delete proxy;
515  return;
516  }
517  }
518  }
519  }
520 }
The QGraphicsItem class is the base class for all graphical items in a QGraphicsScene.
Definition: qgraphicsitem.h:89
QGraphicsScene * scene
void removeItem(QGraphicsItem *item)
Removes the item item and all its children from the scene.
The QGraphicsProxyWidget class provides a proxy layer for embedding a QWidget in a QGraphicsScene...
bool isWidget() const
Returns true if this item is a widget (i.
QList< QGraphicsItem * > children

◆ updateProxyGeometryFromWidget()

void QGraphicsProxyWidgetPrivate::updateProxyGeometryFromWidget ( )
Warning
This function is not part of the public interface.

Definition at line 430 of file qgraphicsproxywidget.cpp.

431 {
433  if (!widget)
434  return;
435 
436  QRectF widgetGeometry = widget->geometry();
438  if (widget->isWindow()) {
439  QGraphicsProxyWidget *proxyParent = 0;
440  if (parentWidget && (proxyParent = qobject_cast<QGraphicsProxyWidget *>(q->parentWidget()))) {
441  // Nested window proxy (e.g., combobox popup), map widget to the
442  // parent widget's global coordinates, and map that to the parent
443  // proxy's child coordinates.
444  widgetGeometry.moveTo(proxyParent->subWidgetRect(parentWidget).topLeft()
445  + parentWidget->mapFromGlobal(widget->pos()));
446  }
447  }
448 
449  // Adjust to size hint if the widget has never been resized.
450  if (!widget->size().isValid())
451  widgetGeometry.setSize(widget->sizeHint());
452 
453  // Assign new geometry.
456  q->setGeometry(widgetGeometry);
459 }
QWidget * parentWidget() const
Returns the parent of this widget, or 0 if it does not have any parent widget.
Definition: qwidget.h:1035
bool isWindow() const
Returns true if the widget is an independent window, otherwise returns false.
Definition: qwidget.h:945
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
QPointF topLeft() const
Returns the position of the rectangle&#39;s top-left corner.
Definition: qrect.h:539
#define Q_Q(Class)
Definition: qglobal.h:2483
The QRectF class defines a rectangle in the plane using floating point precision. ...
Definition: qrect.h:511
QSize size
the size of the widget excluding any window frame
Definition: qwidget.h:165
void setSize(const QSizeF &s)
Sets the size of the rectangle to the given size.
Definition: qrect.h:790
static QWidget * parentWidget(const QWidget *w)
The QGraphicsProxyWidget class provides a proxy layer for embedding a QWidget in a QGraphicsScene...
QPoint pos
the position of the widget within its parent widget
Definition: qwidget.h:163
bool isValid() const
Returns true if both the width and height is equal to or greater than 0; otherwise returns false...
Definition: qsize.h:123
void moveTo(qreal x, qreal t)
Moves the rectangle, leaving the top-left corner at the given position (x, y).
Definition: qrect.h:728
QPoint mapFromGlobal(const QPoint &) const
Translates the global screen coordinate pos to widget coordinates.
QSize sizeHint
the recommended size for the widget
Definition: qwidget.h:195
QRectF subWidgetRect(const QWidget *widget) const
Returns the rectangle for widget, which must be a descendant of widget(), or widget() itself...
QRect geometry
the geometry of the widget relative to its parent and excluding the window frame
Definition: qwidget.h:158

◆ updateProxyInputMethodAcceptanceFromWidget()

void QGraphicsProxyWidgetPrivate::updateProxyInputMethodAcceptanceFromWidget ( )
Warning
This function is not part of the public interface.

Definition at line 464 of file qgraphicsproxywidget.cpp.

465 {
467  if (!widget)
468  return;
469 
470  QWidget *focusWidget = widget->focusWidget();
471  if (!focusWidget)
472  focusWidget = widget;
475 }
QWidget * focusWidget() const
Returns the last child of this widget that setFocus had been called on.
Definition: qwidget.cpp:6863
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
#define Q_Q(Class)
Definition: qglobal.h:2483
bool testAttribute(Qt::WidgetAttribute) const
Returns true if attribute attribute is set on this widget; otherwise returns false.
Definition: qwidget.h:1041
The QGraphicsProxyWidget class provides a proxy layer for embedding a QWidget in a QGraphicsScene...

◆ updateWidgetGeometryFromProxy()

void QGraphicsProxyWidgetPrivate::updateWidgetGeometryFromProxy ( )
Warning
This function is not part of the public interface.

Definition at line 423 of file qgraphicsproxywidget.cpp.

424 {
425 }

Properties

◆ dragDropWidget

QWidget* QGraphicsProxyWidgetPrivate::dragDropWidget

Definition at line 100 of file qgraphicsproxywidget_p.h.

◆ embeddedMouseGrabber

QPointer<QWidget> QGraphicsProxyWidgetPrivate::embeddedMouseGrabber

Definition at line 99 of file qgraphicsproxywidget_p.h.

Referenced by sendWidgetMouseEvent().

◆ enabledChangeMode

quint32 QGraphicsProxyWidgetPrivate::enabledChangeMode

Definition at line 118 of file qgraphicsproxywidget_p.h.

◆ focusFromWidgetToProxy

quint32 QGraphicsProxyWidgetPrivate::focusFromWidgetToProxy

Definition at line 122 of file qgraphicsproxywidget_p.h.

◆ lastDropAction

Qt::DropAction QGraphicsProxyWidgetPrivate::lastDropAction

Definition at line 101 of file qgraphicsproxywidget_p.h.

◆ lastWidgetUnderMouse

QPointer<QWidget> QGraphicsProxyWidgetPrivate::lastWidgetUnderMouse

Definition at line 98 of file qgraphicsproxywidget_p.h.

Referenced by sendWidgetMouseEvent().

◆ paletteChangeMode

quint32 QGraphicsProxyWidgetPrivate::paletteChangeMode

Definition at line 120 of file qgraphicsproxywidget_p.h.

◆ posChangeMode

quint32 QGraphicsProxyWidgetPrivate::posChangeMode

Definition at line 115 of file qgraphicsproxywidget_p.h.

Referenced by updateProxyGeometryFromWidget().

◆ proxyIsGivingFocus

quint32 QGraphicsProxyWidgetPrivate::proxyIsGivingFocus

Definition at line 123 of file qgraphicsproxywidget_p.h.

◆ sizeChangeMode

quint32 QGraphicsProxyWidgetPrivate::sizeChangeMode

Definition at line 116 of file qgraphicsproxywidget_p.h.

Referenced by updateProxyGeometryFromWidget().

◆ styleChangeMode

quint32 QGraphicsProxyWidgetPrivate::styleChangeMode

Definition at line 119 of file qgraphicsproxywidget_p.h.

◆ tooltipChangeMode

quint32 QGraphicsProxyWidgetPrivate::tooltipChangeMode

Definition at line 121 of file qgraphicsproxywidget_p.h.

◆ visibleChangeMode

quint32 QGraphicsProxyWidgetPrivate::visibleChangeMode

Definition at line 117 of file qgraphicsproxywidget_p.h.

◆ widget

QPointer<QWidget> QGraphicsProxyWidgetPrivate::widget

The documentation for this class was generated from the following files: