QtBase  v6.3.1
qgraphicswidget.cpp
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2021 The Qt Company Ltd.
4 ** Contact: https://www.qt.io/licensing/
5 **
6 ** This file is part of the QtWidgets module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and The Qt Company. For licensing terms
14 ** and conditions see https://www.qt.io/terms-conditions. For further
15 ** information use the contact form at https://www.qt.io/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 3 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL3 included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 3 requirements
23 ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
24 **
25 ** GNU General Public License Usage
26 ** Alternatively, this file may be used under the terms of the GNU
27 ** General Public License version 2.0 or (at your option) the GNU General
28 ** Public license version 3 or any later version approved by the KDE Free
29 ** Qt Foundation. The licenses are as published by the Free Software
30 ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
31 ** included in the packaging of this file. Please review the following
32 ** information to ensure the GNU General Public License requirements will
33 ** be met: https://www.gnu.org/licenses/gpl-2.0.html and
34 ** https://www.gnu.org/licenses/gpl-3.0.html.
35 **
36 ** $QT_END_LICENSE$
37 **
38 ****************************************************************************/
39 
40 #include "qglobal.h"
41 
42 #include "qgraphicswidget.h"
43 #include "qgraphicswidget_p.h"
44 #include "qgraphicslayout.h"
45 #include "qgraphicslayout_p.h"
46 #include "qgraphicsscene.h"
47 #include "qgraphicssceneevent.h"
48 
49 #ifndef QT_NO_ACTION
50 #include <private/qaction_p.h>
51 #endif
52 #include <private/qapplication_p.h>
53 #include <private/qgraphicsscene_p.h>
54 #ifndef QT_NO_SHORTCUT
55 #include <private/qshortcutmap_p.h>
56 #endif
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>
65 
66 #include <qdebug.h>
67 
69 
178 {
179  Q_D(QGraphicsWidget);
180  d->init(parent, wFlags);
181 }
182 
190 {
191  Q_D(QGraphicsWidget);
192  d->init(parent, wFlags);
193 }
194 
195 /*
196  \internal
197  \class QGraphicsWidgetStyles
198 
199  We use this thread-safe class to maintain a hash of styles for widgets
200  styles. Note that QApplication::style() itself isn't thread-safe, QStyle
201  isn't thread-safe, and we don't have a thread-safe factory for creating
202  the default style, nor cloning a style.
203 */
205 {
206 public:
208  {
209  QMutexLocker locker(&mutex);
210  return styles.value(widget, 0);
211  }
212 
214  {
215  QMutexLocker locker(&mutex);
216  if (style)
217  styles[widget] = style;
218  else
219  styles.remove(widget);
220  }
221 
222 private:
224  mutable QMutex mutex;
225 };
227 
228 
232 {
233  Q_D(QGraphicsWidget);
234 #ifndef QT_NO_ACTION
235  // Remove all actions from this widget
236  for (auto action : qAsConst(d->actions)) {
237  QActionPrivate *apriv = action->d_func();
238  apriv->associatedObjects.removeAll(this);
239  }
240  d->actions.clear();
241 #endif
242 
243  if (QGraphicsScene *scn = scene()) {
244  QGraphicsScenePrivate *sceneD = scn->d_func();
245  if (sceneD->tabFocusFirst == this)
246  sceneD->tabFocusFirst = (d->focusNext == this ? nullptr : d->focusNext);
247  }
248  d->focusPrev->d_func()->focusNext = d->focusNext;
249  d->focusNext->d_func()->focusPrev = d->focusPrev;
250 
251  // Play it really safe
252  d->focusNext = this;
253  d->focusPrev = this;
254 
255  clearFocus();
256 
257  //we check if we have a layout previously
258  if (d->layout) {
259  QGraphicsLayout *temp = d->layout;
260  const auto items = childItems();
261  for (QGraphicsItem *item : items) {
262  // In case of a custom layout which doesn't remove and delete items, we ensure that
263  // the parent layout item does not point to the deleted layout. This code is here to
264  // avoid regression from 4.4 to 4.5, because according to 4.5 docs it is not really needed.
265  if (item->isWidget()) {
266  QGraphicsWidget *widget = static_cast<QGraphicsWidget *>(item);
267  if (widget->parentLayoutItem() == d->layout)
268  widget->setParentLayoutItem(nullptr);
269  }
270  }
271  d->layout = nullptr;
272  delete temp;
273  }
274 
275  // Remove this graphics widget from widgetStyles
276  widgetStyles()->setStyleForWidget(this, nullptr);
277 
278  // Unset the parent here, when we're still a QGraphicsWidget.
279  // It is otherwise done in ~QGraphicsItem() where we'd be
280  // calling QGraphicsWidget members on an ex-QGraphicsWidget object
281  setParentItem(nullptr);
282 }
283 
308 {
310 }
311 
313 {
314  setGeometry(QRectF(pos(), size));
315 }
316 
354 {
355  QGraphicsWidgetPrivate *wd = QGraphicsWidget::d_func();
356  // Package relayout of children in a scope guard so we can just return early
357  // when this widget's geometry is sorted out.
358  const auto relayoutChildren = qScopeGuard([this, wd]() {
360  if (QGraphicsLayout *lay = wd->layout) {
361  if (!lay->isActivated()) {
362  QEvent layoutRequest(QEvent::LayoutRequest);
363  QCoreApplication::sendEvent(this, &layoutRequest);
364  }
365  }
366  }
367  });
368 
370  QRectF newGeom;
371  QPointF oldPos = d->geom.topLeft();
372  if (!wd->inSetPos) {
374  newGeom = rect;
375  newGeom.setSize(rect.size().expandedTo(effectiveSizeHint(Qt::MinimumSize))
376  .boundedTo(effectiveSizeHint(Qt::MaximumSize)));
377 
378  if (newGeom == d->geom)
379  return;
380 
381  // setPos triggers ItemPositionChange, which can adjust position
382  wd->inSetGeometry = 1;
383  setPos(newGeom.topLeft());
384  wd->inSetGeometry = 0;
385  newGeom.moveTopLeft(pos());
386 
387  if (newGeom == d->geom)
388  return;
389 
390  // Update and prepare to change the geometry (remove from index) if
391  // the size has changed.
392  if (wd->scene && rect.topLeft() == d->geom.topLeft())
393  prepareGeometryChange();
394  }
395 
396  // Update the layout item geometry
397  if (oldPos != pos()) {
398  // Send move event.
400  event.setOldPos(oldPos);
401  event.setNewPos(pos());
403  if (wd->inSetPos) {
404  // Set the new position:
405  d->geom.moveTopLeft(pos());
406  emit geometryChanged();
407  return;
408  }
409  }
410 
411  QSizeF oldSize = size();
413  // Send resize event, if appropriate:
414  if (newGeom.size() != oldSize) {
415  if (oldSize.width() != newGeom.size().width())
416  emit widthChanged();
417  if (oldSize.height() != newGeom.size().height())
418  emit heightChanged();
419  QGraphicsLayout *lay = wd->layout;
422  re.setOldSize(oldSize);
423  re.setNewSize(newGeom.size());
424  QCoreApplication::sendEvent(this, &re);
425  }
426  }
427 
428  emit geometryChanged();
429 }
430 
488 {
489  Q_D(QGraphicsWidget);
490 
491  if (!d->margins && margins.isNull())
492  return;
493  d->ensureMargins();
494  if (*d->margins == margins)
495  return;
496 
497  *d->margins = margins;
498 
499  if (QGraphicsLayout *l = d->layout)
500  l->invalidate();
501  else
502  updateGeometry();
503 
506 }
507 
515 {
517 }
518 
527 {
528  Q_D(const QGraphicsWidget);
529  if (left || top || right || bottom)
530  d->ensureMargins();
531  if (left)
532  *left = d->margins->left();
533  if (top)
534  *top = d->margins->top();
535  if (right)
536  *right = d->margins->right();
537  if (bottom)
538  *bottom = d->margins->bottom();
539 }
540 
553 {
554  Q_D(QGraphicsWidget);
555 
556  if (!d->windowFrameMargins && margins.isNull())
557  return;
558  d->ensureWindowFrameMargins();
559  const bool unchanged = *d->windowFrameMargins == margins;
560  if (d->setWindowFrameMargins && unchanged)
561  return;
562  if (!unchanged)
564  *d->windowFrameMargins = margins;
565  d->setWindowFrameMargins = true;
566 }
567 
574 {
576 }
577 
586 {
587  Q_D(const QGraphicsWidget);
588  if (left || top || right || bottom)
589  d->ensureWindowFrameMargins();
590  if (left)
591  *left = d->windowFrameMargins->left();
592  if (top)
593  *top = d->windowFrameMargins->top();
594  if (right)
595  *right = d->windowFrameMargins->right();
596  if (bottom)
597  *bottom = d->windowFrameMargins->bottom();
598 }
599 
606 {
607  Q_D(QGraphicsWidget);
608  if ((d->windowFlags & Qt::Window) && (d->windowFlags & Qt::WindowType_Mask) != Qt::Popup &&
609  (d->windowFlags & Qt::WindowType_Mask) != Qt::ToolTip && !(d->windowFlags & Qt::FramelessWindowHint)) {
611  d->initStyleOptionTitleBar(&bar);
612  QStyle *style = this->style();
614  qreal titleBarHeight = d->titleBarHeight(bar);
615  setWindowFrameMargins(margin, titleBarHeight, margin, margin);
616  } else {
617  setWindowFrameMargins(0, 0, 0, 0);
618  }
619  d->setWindowFrameMargins = false;
620 }
621 
629 {
630  Q_D(const QGraphicsWidget);
631  return d->windowFrameMargins
632  ? geometry().adjusted(-d->windowFrameMargins->left(), -d->windowFrameMargins->top(),
633  d->windowFrameMargins->right(), d->windowFrameMargins->bottom())
634  : geometry();
635 }
636 
643 {
644  Q_D(const QGraphicsWidget);
645  return d->windowFrameMargins
646  ? rect().adjusted(-d->windowFrameMargins->left(), -d->windowFrameMargins->top(),
647  d->windowFrameMargins->right(), d->windowFrameMargins->bottom())
648  : rect();
649 }
650 
694 {
695  Q_ASSERT(option);
696 
697  option->state = QStyle::State_None;
698  if (isEnabled())
699  option->state |= QStyle::State_Enabled;
700  if (hasFocus())
701  option->state |= QStyle::State_HasFocus;
702  // if (window->testAttribute(Qt::WA_KeyboardFocusChange)) // ### Window
703  // option->state |= QStyle::State_KeyboardFocusChange;
704  if (isUnderMouse())
706  if (QGraphicsWidget *w = window()) {
707  if (w->isActiveWindow())
708  option->state |= QStyle::State_Active;
709  }
710  if (isWindow())
711  option->state |= QStyle::State_Window;
712  /*
713  ###
714 #ifdef QT_KEYPAD_NAVIGATION
715  if (widget->hasEditFocus())
716  state |= QStyle::State_HasEditFocus;
717 #endif
718  */
719  option->direction = layoutDirection();
720  option->rect = rect().toRect(); // ### truncation!
721  option->palette = palette();
722  if (!isEnabled()) {
723  option->palette.setCurrentColorGroup(QPalette::Disabled);
724  } else if (isActiveWindow()) {
725  option->palette.setCurrentColorGroup(QPalette::Active);
726  } else {
727  option->palette.setCurrentColorGroup(QPalette::Inactive);
728  }
729  option->fontMetrics = QFontMetrics(font());
730  option->styleObject = const_cast<QGraphicsWidget *>(this);
731 }
732 
736 QSizeF QGraphicsWidget::sizeHint(Qt::SizeHint which, const QSizeF &constraint) const
737 {
738  Q_D(const QGraphicsWidget);
739  QSizeF sh;
740  if (d->layout) {
741  QSizeF marginSize(0,0);
742  if (d->margins) {
743  marginSize = QSizeF(d->margins->left() + d->margins->right(),
744  d->margins->top() + d->margins->bottom());
745  }
746  sh = d->layout->effectiveSizeHint(which, constraint - marginSize);
747  sh += marginSize;
748  } else {
749  switch (which) {
750  case Qt::MinimumSize:
751  sh = QSizeF(0, 0);
752  break;
753  case Qt::PreferredSize:
754  sh = QSizeF(50, 50); //rather arbitrary
755  break;
756  case Qt::MaximumSize:
758  break;
759  default:
760  qWarning("QGraphicsWidget::sizeHint(): Don't know how to handle the value of 'which'");
761  break;
762  }
763  }
764  return sh;
765 }
766 
801 {
802  Q_D(const QGraphicsWidget);
803  return d->layout;
804 }
805 
826 {
827  Q_D(QGraphicsWidget);
828  if (d->layout == l)
829  return;
830  d->setLayout_helper(l);
831  if (!l)
832  return;
833 
834  // Prevent assigning a layout that is already assigned to another widget.
835  QGraphicsLayoutItem *oldParent = l->parentLayoutItem();
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",
839  metaObject()->className(), qPrintable(objectName()));
840  return;
841  }
842 
843  // Install and activate the layout.
844  l->setParentLayoutItem(this);
845  l->d_func()->reparentChildItems(this);
846  l->invalidate();
848 }
849 
859 {
861  // What if sz is not valid?!
862  if (sz.isValid())
863  resize(sz);
864 }
865 
893 {
895 }
897 {
898  Q_D(QGraphicsWidget);
900  d->setLayoutDirection_helper(direction);
901 }
903 {
904  Q_D(QGraphicsWidget);
906  d->resolveLayoutDirection();
907 }
908 
918 {
919  if (QStyle *style = widgetStyles()->styleForWidget(this))
920  return style;
921  // ### This is not thread-safe. QApplication::style() is not thread-safe.
922  return scene() ? scene()->style() : QApplication::style();
923 }
924 
939 {
940  setAttribute(Qt::WA_SetStyle, style != nullptr);
941  widgetStyles()->setStyleForWidget(this, style);
942 
943  // Deliver StyleChange to the widget itself (doesn't propagate).
946 }
947 
971 {
972  Q_D(const QGraphicsWidget);
973  QFont fnt = d->font;
974  fnt.setResolveMask(fnt.resolveMask() | d->inheritedFontResolveMask);
975  return fnt;
976 }
978 {
979  Q_D(QGraphicsWidget);
981 
982  QFont naturalFont = d->naturalWidgetFont();
983  QFont resolvedFont = font.resolve(naturalFont);
984  d->setFont_helper(resolvedFont);
985 }
986 
1013 {
1014  Q_D(const QGraphicsWidget);
1015  return d->palette;
1016 }
1018 {
1019  Q_D(QGraphicsWidget);
1021 
1022  QPalette naturalPalette = d->naturalWidgetPalette();
1023  QPalette resolvedPalette = palette.resolve(naturalPalette);
1024  d->setPalette_helper(resolvedPalette);
1025 }
1026 
1044 {
1045  Q_D(const QGraphicsWidget);
1046  return d->autoFillBackground;
1047 }
1049 {
1050  Q_D(QGraphicsWidget);
1051  if (d->autoFillBackground != enabled) {
1052  d->autoFillBackground = enabled;
1053  update();
1054  }
1055 }
1056 
1067 {
1070 
1071  if (parentItem && parentItem->isLayout()) {
1073  static_cast<QGraphicsLayout *>(parentItem)->invalidate();
1074  } else {
1075  parentItem->updateGeometry();
1076  }
1077  } else {
1078  if (parentItem) {
1079  // This is for custom layouting
1080  QGraphicsWidget *parentWid = parentWidget(); //###
1081  if (parentWid->isVisible())
1083  } else {
1091  }
1093  bool wasResized = testAttribute(Qt::WA_Resized);
1094  resize(size()); // this will restrict the size
1095  setAttribute(Qt::WA_Resized, wasResized);
1096  }
1097  }
1098 }
1099 
1121 {
1122  Q_D(QGraphicsWidget);
1123  switch (change) {
1124  case ItemEnabledHasChanged: {
1125  // Send EnabledChange after the enabled state has changed.
1128  break;
1129  }
1130  case ItemVisibleChange:
1131  if (value.toBool()) {
1132  // Send Show event before the item has been shown.
1133  QShowEvent event;
1135  bool resized = testAttribute(Qt::WA_Resized);
1136  if (!resized) {
1137  adjustSize();
1138  setAttribute(Qt::WA_Resized, false);
1139  }
1140  }
1141 
1142  // layout size hint only changes if an item changes from/to explicitly hidden state
1143  if (value.toBool() || d->explicitlyHidden)
1144  updateGeometry();
1145  break;
1146  case ItemVisibleHasChanged:
1147  if (!value.toBool()) {
1148  // Send Hide event after the item has been hidden.
1149  QHideEvent event;
1151  }
1152  break;
1154  d->setGeometryFromSetPos();
1155  break;
1156  case ItemParentChange: {
1157  // Deliver ParentAboutToChange.
1160  break;
1161  }
1162  case ItemParentHasChanged: {
1163  // Deliver ParentChange.
1166  break;
1167  }
1168  case ItemCursorHasChanged: {
1169  // Deliver CursorChange.
1172  break;
1173  }
1174  case ItemToolTipHasChanged: {
1175  // Deliver ToolTipChange.
1178  break;
1179  }
1180  default:
1181  break;
1182  }
1183  return QGraphicsItem::itemChange(change, value);
1184 }
1185 
1213 {
1214  Q_UNUSED(propertyName);
1215  return value;
1216 }
1217 
1230 {
1232 }
1233 
1248 {
1249  Q_D(QGraphicsWidget);
1250  switch (event->type()) {
1252  d->windowFrameMousePressEvent(static_cast<QGraphicsSceneMouseEvent *>(event));
1253  break;
1255  d->ensureWindowData();
1256  if (d->windowData->grabbedSection != Qt::NoSection) {
1257  d->windowFrameMouseMoveEvent(static_cast<QGraphicsSceneMouseEvent *>(event));
1258  event->accept();
1259  }
1260  break;
1262  d->windowFrameMouseReleaseEvent(static_cast<QGraphicsSceneMouseEvent *>(event));
1263  break;
1265  d->windowFrameHoverMoveEvent(static_cast<QGraphicsSceneHoverEvent *>(event));
1266  break;
1268  d->windowFrameHoverLeaveEvent(static_cast<QGraphicsSceneHoverEvent *>(event));
1269  break;
1270  default:
1271  break;
1272  }
1273  return event->isAccepted();
1274 }
1275 
1295 {
1296  Q_D(const QGraphicsWidget);
1297 
1298  const QRectF r = windowFrameRect();
1299  if (!r.contains(pos))
1300  return Qt::NoSection;
1301 
1302  const qreal left = r.left();
1303  const qreal top = r.top();
1304  const qreal right = r.right();
1305  const qreal bottom = r.bottom();
1306  const qreal x = pos.x();
1307  const qreal y = pos.y();
1308 
1309  const qreal cornerMargin = 20;
1310  //### Not sure of this one, it should be the same value for all edges.
1311  const qreal windowFrameWidth = d->windowFrameMargins
1312  ? d->windowFrameMargins->left() : 0;
1313 
1315  if (x <= left + cornerMargin) {
1316  if (y <= top + windowFrameWidth || (x <= left + windowFrameWidth && y <= top + cornerMargin)) {
1318  } else if (y >= bottom - windowFrameWidth || (x <= left + windowFrameWidth && y >= bottom - cornerMargin)) {
1320  } else if (x <= left + windowFrameWidth) {
1321  s = Qt::LeftSection;
1322  }
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) {
1329  s = Qt::RightSection;
1330  }
1331  } else if (y <= top + windowFrameWidth) {
1332  s = Qt::TopSection;
1333  } else if (y >= bottom - windowFrameWidth) {
1334  s = Qt::BottomSection;
1335  }
1336  if (s == Qt::NoSection) {
1337  QRectF r1 = r;
1338  r1.setHeight(d->windowFrameMargins
1339  ? d->windowFrameMargins->top() : 0);
1340  if (r1.contains(pos))
1341  s = Qt::TitleBarArea;
1342  }
1343  return s;
1344 }
1345 
1384 {
1385  Q_D(QGraphicsWidget);
1386  // Forward the event to the layout first.
1387  if (d->layout)
1388  d->layout->widgetEvent(event);
1389 
1390  // Handle the event itself.
1391  switch (event->type()) {
1393  moveEvent(static_cast<QGraphicsSceneMoveEvent *>(event));
1394  break;
1396  resizeEvent(static_cast<QGraphicsSceneResizeEvent *>(event));
1397  break;
1398  case QEvent::Show:
1399  showEvent(static_cast<QShowEvent *>(event));
1400  break;
1401  case QEvent::Hide:
1402  hideEvent(static_cast<QHideEvent *>(event));
1403  break;
1404  case QEvent::Polish:
1405  polishEvent();
1406  d->polished = true;
1407  if (!d->font.isCopyOf(QApplication::font()))
1408  d->updateFont(d->font);
1409  break;
1412  update();
1413  break;
1415  if (isVisible()) {
1416  event->accept();
1417  update();
1418  }
1419  break;
1420  // Taken from QWidget::event
1422  case QEvent::EnabledChange:
1423  case QEvent::FontChange:
1424  case QEvent::StyleChange:
1425  case QEvent::PaletteChange:
1426  case QEvent::ParentChange:
1429  changeEvent(event);
1430  break;
1431  case QEvent::Close:
1433  break;
1434  case QEvent::GrabMouse:
1436  break;
1437  case QEvent::UngrabMouse:
1439  break;
1440  case QEvent::GrabKeyboard:
1442  break;
1445  break;
1447  if (d->hasDecoration() && windowFrameEvent(event))
1448  return true;
1449  break;
1453  d->ensureWindowData();
1454  if (d->hasDecoration() && d->windowData->grabbedSection != Qt::NoSection)
1455  return windowFrameEvent(event);
1456  break;
1460  if (d->hasDecoration()) {
1462  // Filter out hover events if they were sent to us only because of the
1463  // decoration (special case in QGraphicsScenePrivate::dispatchHoverEvent).
1464  if (!acceptHoverEvents())
1465  return true;
1466  }
1467  break;
1468  default:
1469  break;
1470  }
1471  return QObject::event(event);
1472 }
1473 
1485 {
1486  Q_D(QGraphicsWidget);
1487  switch (event->type()) {
1488  case QEvent::StyleChange:
1489  // ### Don't unset if the margins are explicitly set.
1491  if (d->layout)
1492  d->layout->invalidate();
1493  Q_FALLTHROUGH();
1494  case QEvent::FontChange:
1495  update();
1496  updateGeometry();
1497  break;
1498  case QEvent::PaletteChange:
1499  update();
1500  break;
1501  case QEvent::ParentChange:
1502  d->resolveFont(d->inheritedFontResolveMask);
1503  d->resolvePalette(d->inheritedPaletteResolveMask);
1504  break;
1505  default:
1506  break;
1507  }
1508 }
1509 
1518 {
1519  event->accept();
1520 }
1521 
1526 {
1527  Q_UNUSED(event);
1528  if (focusPolicy() != Qt::NoFocus)
1529  update();
1530 }
1531 
1552 {
1553  Q_D(QGraphicsWidget);
1554  // Let the parent's focusNextPrevChild implementation decide what to do.
1555  QGraphicsWidget *parent = nullptr;
1556  if (!isWindow() && (parent = parentWidget()))
1557  return parent->focusNextPrevChild(next);
1558  if (!d->scene)
1559  return false;
1560  if (d->scene->focusNextPrevChild(next))
1561  return true;
1562  if (isWindow()) {
1564  if (hasFocus())
1565  return true;
1566  }
1567  return false;
1568 }
1569 
1574 {
1575  Q_UNUSED(event);
1576  if (focusPolicy() != Qt::NoFocus)
1577  update();
1578 }
1579 
1593 {
1595  // is hidden.
1596  Q_UNUSED(event);
1597 }
1598 
1615 {
1616  // ### Last position is always == current position
1617  Q_UNUSED(event);
1618 }
1619 
1629 {
1630 }
1631 
1649 {
1650  Q_UNUSED(event);
1651 }
1652 
1666 {
1667  Q_UNUSED(event);
1668 }
1669 
1674 {
1675  Q_UNUSED(event);
1676 }
1677 
1682 {
1684 }
1685 
1693 {
1694  Q_UNUSED(event);
1695 }
1696 
1704 {
1705  Q_UNUSED(event);
1706 }
1707 
1715 {
1716  Q_UNUSED(event);
1717 }
1718 
1726 {
1727  Q_UNUSED(event);
1728 }
1729 
1736 {
1738 }
1739 
1757 Qt::WindowFlags QGraphicsWidget::windowFlags() const
1758 {
1759  Q_D(const QGraphicsWidget);
1760  return d->windowFlags;
1761 }
1762 void QGraphicsWidget::setWindowFlags(Qt::WindowFlags wFlags)
1763 {
1764  Q_D(QGraphicsWidget);
1765  if (d->windowFlags == wFlags)
1766  return;
1767  bool wasPopup = (d->windowFlags & Qt::WindowType_Mask) == Qt::Popup;
1768 
1769  d->adjustWindowFlags(&wFlags);
1770  d->windowFlags = wFlags;
1771  if (!d->setWindowFrameMargins)
1773 
1774  setFlag(ItemIsPanel, d->windowFlags & Qt::Window);
1775 
1776  bool isPopup = (d->windowFlags & Qt::WindowType_Mask) == Qt::Popup;
1777  if (d->scene && isVisible() && wasPopup != isPopup) {
1778  // Popup state changed; update implicit mouse grab.
1779  if (!isPopup)
1780  d->scene->d_func()->removePopup(this);
1781  else
1782  d->scene->d_func()->addPopup(this);
1783  }
1784 
1785  if (d->scene && d->scene->d_func()->allItemsIgnoreHoverEvents && d->hasDecoration()) {
1786  d->scene->d_func()->allItemsIgnoreHoverEvents = false;
1787  d->scene->d_func()->enableMouseTrackingOnViews();
1788  }
1789 }
1790 
1802 {
1803  return isActive();
1804 }
1805 
1816 {
1817  Q_D(QGraphicsWidget);
1818  d->ensureWindowData();
1819  d->windowData->windowTitle = title;
1820 }
1822 {
1823  Q_D(const QGraphicsWidget);
1824  return d->windowData ? d->windowData->windowTitle : QString();
1825 }
1826 
1848 {
1849  Q_D(const QGraphicsWidget);
1850  return d->focusPolicy;
1851 }
1853 {
1854  Q_D(QGraphicsWidget);
1855  if (d->focusPolicy == policy)
1856  return;
1857  d->focusPolicy = policy;
1858  if (hasFocus() && policy == Qt::NoFocus)
1859  clearFocus();
1861 }
1862 
1871 {
1872  Q_D(const QGraphicsWidget);
1873  if (d->subFocusItem && d->subFocusItem->d_ptr->isWidget)
1874  return static_cast<QGraphicsWidget *>(d->subFocusItem);
1875  return nullptr;
1876 }
1877 
1878 #ifndef QT_NO_SHORTCUT
1907 {
1908  Q_ASSERT(qApp);
1909  if (sequence.isEmpty())
1910  return 0;
1911  // ### setAttribute(Qt::WA_GrabbedShortcut);
1912  return QGuiApplicationPrivate::instance()->shortcutMap.addShortcut(this, sequence, context, qWidgetShortcutContextMatcher);
1913 }
1914 
1933 {
1934  Q_ASSERT(qApp);
1935  if (id)
1936  QGuiApplicationPrivate::instance()->shortcutMap.removeShortcut(id, this, 0);
1937 }
1938 
1954 {
1955  Q_ASSERT(qApp);
1956  if (id)
1957  QGuiApplicationPrivate::instance()->shortcutMap.setShortcutEnabled(enabled, id, this, 0);
1958 }
1959 
1969 {
1970  Q_ASSERT(qApp);
1971  if (id)
1972  QGuiApplicationPrivate::instance()->shortcutMap.setShortcutAutoRepeat(enabled, id, this, 0);
1973 }
1974 #endif
1975 
1976 #ifndef QT_NO_ACTION
1992 {
1993  insertAction(nullptr, action);
1994 }
1995 
2004 {
2005  for (int i = 0; i < actions.count(); ++i)
2006  insertAction(nullptr, actions.at(i));
2007 }
2008 
2022 {
2023  if (!action) {
2024  qWarning("QWidget::insertAction: Attempt to insert null action");
2025  return;
2026  }
2027 
2028  Q_D(QGraphicsWidget);
2029  int index = d->actions.indexOf(action);
2030  if (index != -1)
2031  d->actions.removeAt(index);
2032 
2033  int pos = d->actions.indexOf(before);
2034  if (pos < 0) {
2035  before = nullptr;
2036  pos = d->actions.size();
2037  }
2038  d->actions.insert(pos, action);
2039 
2040  if (index == -1) {
2041  QActionPrivate *apriv = action->d_func();
2042  apriv->associatedObjects.append(this);
2043  }
2044 
2047 }
2048 
2061 {
2062  for (int i = 0; i < actions.count(); ++i)
2063  insertAction(before, actions.at(i));
2064 }
2065 
2074 {
2075  if (!action)
2076  return;
2077 
2078  Q_D(QGraphicsWidget);
2079 
2080  QActionPrivate *apriv = action->d_func();
2081  apriv->associatedObjects.removeAll(this);
2082 
2083  if (d->actions.removeAll(action)) {
2086  }
2087 }
2088 
2098 {
2099  Q_D(const QGraphicsWidget);
2100  return d->actions;
2101 }
2102 #endif
2103 
2129 {
2130  if (!first && !second) {
2131  qWarning("QGraphicsWidget::setTabOrder(0, 0) is undefined");
2132  return;
2133  }
2134  if ((first && second) && first->scene() != second->scene()) {
2135  qWarning("QGraphicsWidget::setTabOrder: scenes %p and %p are different",
2136  first->scene(), second->scene());
2137  return;
2138  }
2139  QGraphicsScene *scene = first ? first->scene() : second->scene();
2140  if (!scene) {
2141  qWarning("QGraphicsWidget::setTabOrder: assigning tab order from/to the"
2142  " scene requires the item to be in a scene.");
2143  return;
2144  }
2145 
2146  // If either first or second are 0, the scene's tabFocusFirst is updated
2147  // to point to the first item in the scene's focus chain. Then first or
2148  // second are set to point to tabFocusFirst.
2149  QGraphicsScenePrivate *sceneD = scene->d_func();
2150  if (!first) {
2151  sceneD->tabFocusFirst = second;
2152  return;
2153  }
2154  if (!second) {
2155  sceneD->tabFocusFirst = first->d_func()->focusNext;
2156  return;
2157  }
2158 
2159  // Both first and second are != 0.
2160  QGraphicsWidget *firstFocusNext = first->d_func()->focusNext;
2161  if (firstFocusNext == second) {
2162  // Nothing to do.
2163  return;
2164  }
2165 
2166  // Update the focus chain.
2167  QGraphicsWidget *secondFocusPrev = second->d_func()->focusPrev;
2168  QGraphicsWidget *secondFocusNext = second->d_func()->focusNext;
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;
2175 
2176  Q_ASSERT(first->d_func()->focusNext->d_func()->focusPrev == first);
2177  Q_ASSERT(first->d_func()->focusPrev->d_func()->focusNext == first);
2178 
2179  Q_ASSERT(second->d_func()->focusNext->d_func()->focusPrev == second);
2180  Q_ASSERT(second->d_func()->focusPrev->d_func()->focusNext == second);
2181 
2182 }
2183 
2194 {
2195  Q_D(QGraphicsWidget);
2196  // ### most flags require some immediate action
2197  // ### we might want to qWarn use of unsupported attributes
2198  // ### we might want to not use Qt::WidgetAttribute, but roll our own instead
2199  d->setAttribute(attribute, on);
2200 }
2201 
2209 {
2210  Q_D(const QGraphicsWidget);
2211  return d->testAttribute(attribute);
2212 }
2213 
2226 {
2227  return Type;
2228 }
2229 
2234 {
2235  Q_UNUSED(painter);
2236  Q_UNUSED(option);
2237  Q_UNUSED(widget);
2238 }
2239 
2252  QWidget *widget)
2253 {
2254  const bool fillBackground = !testAttribute(Qt::WA_OpaquePaintEvent)
2256  QGraphicsProxyWidget *proxy = qobject_cast<QGraphicsProxyWidget *>(this);
2257  const bool embeddedWidgetFillsOwnBackground = proxy && proxy->widget();
2258 
2259  if (rect().contains(option->exposedRect)) {
2260  if (fillBackground && !embeddedWidgetFillsOwnBackground)
2261  painter->fillRect(option->exposedRect, palette().window());
2262  return;
2263  }
2264 
2265  Q_D(QGraphicsWidget);
2266 
2269  bar.QStyleOption::operator=(*option);
2270  d->initStyleOptionTitleBar(&bar); // this clear flags in bar.state
2271  d->ensureWindowData();
2272  bar.state.setFlag(QStyle::State_MouseOver, d->windowData->buttonMouseOver);
2273  bar.state.setFlag(QStyle::State_Sunken, d->windowData->buttonSunken);
2274  bar.rect = windowFrameRect;
2275 
2276  // translate painter to make the style happy
2277  const QPointF styleOrigin = this->windowFrameRect().topLeft();
2278  painter->translate(styleOrigin);
2279 
2280 #ifdef Q_OS_MAC
2281  const QSize pixmapSize = windowFrameRect.size();
2282  if (pixmapSize.width() <= 0 || pixmapSize.height() <= 0)
2283  return;
2284  QPainter *realPainter = painter;
2285  QPixmap pm(pixmapSize);
2286  painter = new QPainter(&pm);
2287 #endif
2288 
2289  // Fill background
2291  bool setMask = style()->styleHint(QStyle::SH_WindowFrame_Mask, &bar, widget, &mask) && !mask.region.isEmpty();
2292  bool hasBorder = !style()->styleHint(QStyle::SH_TitleBar_NoBorder, &bar, widget);
2293  int frameWidth = style()->pixelMetric(QStyle::PM_MdiSubWindowFrameWidth, &bar, widget);
2294  if (setMask) {
2295  painter->save();
2297  }
2298  if (fillBackground) {
2299  if (embeddedWidgetFillsOwnBackground) {
2300  // Don't fill the background twice.
2301  QPainterPath windowFrameBackground;
2302  windowFrameBackground.addRect(windowFrameRect);
2303  // Adjust with 0.5 to avoid border artifacts between
2304  // widget background and frame background.
2305  windowFrameBackground.addRect(rect().translated(-styleOrigin).adjusted(0.5, 0.5, -0.5, -0.5));
2306  painter->fillPath(windowFrameBackground, palette().window());
2307  } else {
2309  }
2310  }
2311 
2312  // Draw title
2313  int height = (int)d->titleBarHeight(bar);
2314  bar.rect.setHeight(height);
2315  if (hasBorder) // Frame is painted by PE_FrameWindow
2316  bar.rect.adjust(frameWidth, frameWidth, -frameWidth, 0);
2317 
2318  painter->save();
2319  painter->setFont(QApplication::font("QMdiSubWindowTitleBar"));
2321  painter->restore();
2322  if (setMask)
2323  painter->restore();
2324  // Draw window frame
2325  QStyleOptionFrame frameOptions;
2326  frameOptions.QStyleOption::operator=(*option);
2327  initStyleOption(&frameOptions);
2328  if (!hasBorder)
2330  frameOptions.state.setFlag(QStyle::State_HasFocus, hasFocus());
2331  bool isActive = isActiveWindow();
2332  frameOptions.state.setFlag(QStyle::State_Active, isActive);
2333 
2335  frameOptions.rect = windowFrameRect;
2337  frameOptions.midLineWidth = 1;
2339 
2340 #ifdef Q_OS_MAC
2341  realPainter->drawPixmap(QPoint(), pm);
2342  delete painter;
2343 #endif
2344 }
2345 
2350 {
2351  return windowFrameRect();
2352 }
2353 
2358 {
2360  path.addRect(rect());
2361  return path;
2362 }
2363 
2376 {
2379  if (!closeEvent.isAccepted()) {
2380  return false;
2381  }
2382  // hide
2383  if (isVisible()) {
2384  hide();
2385  }
2387  deleteLater();
2388  }
2389  return true;
2390 }
2391 
2392 #if 0
2393 void QGraphicsWidget::dumpFocusChain()
2394 {
2395  qDebug("=========== Dumping focus chain ==============");
2396  int i = 0;
2397  QGraphicsWidget *next = this;
2398  QSet<QGraphicsWidget*> visited;
2399  do {
2400  if (!next) {
2401  qWarning("Found a focus chain that is not circular, (next == 0)");
2402  break;
2403  }
2404  qDebug() << i++ << QString::number(uint(next), 16) << next->className() << next->data(0) << QString::fromLatin1("focusItem:%1").arg(next->hasFocus() ? '1' : '0') << QLatin1String("next:") << next->d_func()->focusNext->data(0) << QLatin1String("prev:") << next->d_func()->focusPrev->data(0);
2405  if (visited.contains(next)) {
2406  qWarning("Already visited this node. However, I expected to dump until I found myself.");
2407  break;
2408  }
2409  visited << next;
2410  next = next->d_func()->focusNext;
2411  } while (next != this);
2412 }
2413 #endif
2414 
2416 
2417 #include "moc_qgraphicswidget.cpp"
small capitals from c petite p scientific i
[1]
Definition: afcover.h:80
Arabic default style
Definition: afstyles.h:94
#define value
[5]
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...
Definition: qaction.h:65
QObjectList associatedObjects
Definition: qaction_p.h:101
static QStyle * style()
static QFont font()
The QCloseEvent class contains parameters that describe a close event.
Definition: qevent.h:629
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.
Definition: qcoreevent.h:58
@ GraphicsSceneMouseMove
Definition: qcoreevent.h:202
@ Close
Definition: qcoreevent.h:91
@ ActionRemoved
Definition: qcoreevent.h:166
@ ContentsRectChange
Definition: qcoreevent.h:232
@ ParentChange
Definition: qcoreevent.h:93
@ EnabledChange
Definition: qcoreevent.h:147
@ GraphicsSceneMouseRelease
Definition: qcoreevent.h:204
@ ActionAdded
Definition: qcoreevent.h:165
@ LayoutDirectionChange
Definition: qcoreevent.h:137
@ Hide
Definition: qcoreevent.h:90
@ GraphicsSceneMousePress
Definition: qcoreevent.h:203
@ StyleChange
Definition: qcoreevent.h:149
@ GraphicsSceneMove
Definition: qcoreevent.h:239
@ CursorChange
Definition: qcoreevent.h:241
@ LayoutRequest
Definition: qcoreevent.h:125
@ UngrabMouse
Definition: qcoreevent.h:247
@ FontChange
Definition: qcoreevent.h:146
@ Show
Definition: qcoreevent.h:89
@ StyleAnimationUpdate
Definition: qcoreevent.h:285
@ ActivationChange
Definition: qcoreevent.h:148
@ ToolTipChange
Definition: qcoreevent.h:242
@ GraphicsSceneHoverLeave
Definition: qcoreevent.h:209
@ ParentAboutToChange
Definition: qcoreevent.h:94
@ WindowActivate
Definition: qcoreevent.h:96
@ GraphicsSceneMouseDoubleClick
Definition: qcoreevent.h:205
@ GraphicsSceneResize
Definition: qcoreevent.h:238
@ PaletteChange
Definition: qcoreevent.h:107
@ GraphicsSceneHoverEnter
Definition: qcoreevent.h:207
@ UngrabKeyboard
Definition: qcoreevent.h:249
@ GraphicsSceneHoverMove
Definition: qcoreevent.h:208
@ GrabKeyboard
Definition: qcoreevent.h:248
@ Polish
Definition: qcoreevent.h:124
@ WindowDeactivate
Definition: qcoreevent.h:97
@ GrabMouse
Definition: qcoreevent.h:246
The QFocusEvent class contains event parameters for widget focus events. \inmodule QtGui.
Definition: qevent.h:520
The QFont class specifies a query for a font used for drawing text.
Definition: qfont.h:56
QFont resolve(const QFont &) const
Definition: qfont.cpp:1874
void setResolveMask(uint mask)
Definition: qfont.h:275
uint resolveMask() const
Definition: qfont.h:274
The QFontMetrics class provides font metrics information.
Definition: qfontmetrics.h:56
The QGraphicsItem class is the base class for all graphical items in a QGraphicsScene.
Definition: qgraphicsitem.h:83
virtual bool contains(const QPointF &point) const
bool isWidget() const
friend class QGraphicsWidget
void update(const QRectF &rect=QRectF())
QGraphicsWidget * parentWidget() const
virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value)
bool isWindow() const
QGraphicsScene * scene() const
QGraphicsWidget * window() const
bool isEnabled() const
bool acceptHoverEvents() const
bool hasFocus() const
bool isUnderMouse() const
void prepareGeometryChange()
void setFlag(GraphicsItemFlag flag, bool enabled=true)
virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
QGraphicsItem * parentItem() const
bool isVisible() const
void setFocus(Qt::FocusReason focusReason=Qt::OtherFocusReason)
bool isActive() const
virtual bool sceneEvent(QEvent *event)
The QGraphicsLayout class provides the base class for all layouts in Graphics View.
bool isActivated() const
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
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 QGraphicsProxyWidget class provides a proxy layer for embedding a QWidget in a QGraphicsScene.
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.
QStyle * style() const
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 QGraphicsWidget class is the base class for all widget items in a QGraphicsScene.
void removeAction(QAction *action)
virtual void hideEvent(QHideEvent *event)
virtual bool focusNextPrevChild(bool next)
void setStyle(QStyle *style)
void setLayout(QGraphicsLayout *layout)
QStyle * style() const
QRectF geometry
the geometry of the widget
void layoutChanged()
QRectF windowFrameRect() const
void setFocusPolicy(Qt::FocusPolicy policy)
void setContentsMargins(qreal left, qreal top, qreal right, qreal bottom)
void setFont(const QFont &font)
QList< QAction * > actions() const
virtual void moveEvent(QGraphicsSceneMoveEvent *event)
void setWindowFrameMargins(qreal left, qreal top, qreal right, qreal bottom)
virtual bool windowFrameEvent(QEvent *e)
QRectF rect() const
void releaseShortcut(int id)
int type() const override
Qt::WindowFlags windowFlags
the widget's window flags
void setAutoFillBackground(bool enabled)
void addActions(const QList< QAction * > &actions)
virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) override
Qt::WindowType windowType() const
Qt::LayoutDirection layoutDirection
the layout direction for this widget.
virtual void polishEvent()
bool sceneEvent(QEvent *event) override
virtual void paintWindowFrame(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget=nullptr)
bool isActiveWindow() const
bool autoFillBackground
whether the widget background is filled automatically
virtual void closeEvent(QCloseEvent *event)
void setGeometry(const QRectF &rect) override
QPainterPath shape() const override
void resize(const QSizeF &size)
bool event(QEvent *event) override
void getContentsMargins(qreal *left, qreal *top, qreal *right, qreal *bottom) const override
QVariant itemChange(GraphicsItemChange change, const QVariant &value) override
virtual Qt::WindowFrameSection windowFrameSectionAt(const QPointF &pos) const
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget=nullptr) override
void setAttribute(Qt::WidgetAttribute attribute, bool on=true)
QPalette palette
the widget's palette
QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint=QSizeF()) const override
virtual QVariant propertyChange(const QString &propertyName, const QVariant &value)
virtual void ungrabKeyboardEvent(QEvent *event)
void setWindowFlags(Qt::WindowFlags wFlags)
virtual void changeEvent(QEvent *event)
QRectF boundingRect() const override
bool testAttribute(Qt::WidgetAttribute attribute) const
void addAction(QAction *action)
void focusOutEvent(QFocusEvent *event) override
QFont font
the widgets' font
virtual void showEvent(QShowEvent *event)
virtual void ungrabMouseEvent(QEvent *event)
void insertActions(QAction *before, const QList< QAction * > &actions)
void setLayoutDirection(Qt::LayoutDirection direction)
void setShortcutEnabled(int id, bool enabled=true)
virtual void grabKeyboardEvent(QEvent *event)
virtual void initStyleOption(QStyleOption *option) const
void unsetWindowFrameMargins()
void setWindowTitle(const QString &title)
virtual void grabMouseEvent(QEvent *event)
void setPalette(const QPalette &palette)
QRectF windowFrameGeometry() const
Qt::FocusPolicy focusPolicy
the way the widget accepts keyboard focus
QGraphicsLayout * layout
The layout of the widget.
void getWindowFrameMargins(qreal *left, qreal *top, qreal *right, qreal *bottom) const
QSizeF size
the size of the widget
void setShortcutAutoRepeat(int id, bool enabled=true)
int grabShortcut(const QKeySequence &sequence, Qt::ShortcutContext context=Qt::WindowShortcut)
void updateGeometry() override
void focusInEvent(QFocusEvent *event) override
virtual void resizeEvent(QGraphicsSceneResizeEvent *event)
QString windowTitle
This property holds the window title (caption).
static void setTabOrder(QGraphicsWidget *first, QGraphicsWidget *second)
virtual void hoverMoveEvent(QGraphicsSceneHoverEvent *event) override
void insertAction(QAction *before, QAction *action)
QGraphicsWidget * focusWidget() const
QGraphicsLayout * layout
QStyle * styleForWidget(const QGraphicsWidget *widget) const
void setStyleForWidget(QGraphicsWidget *widget, QStyle *style)
static QGuiApplicationPrivate * instance()
bool remove(const Key &key)
Definition: qhash.h:911
T value(const Key &key) const noexcept
Definition: qhash.h:997
The QHideEvent class provides an event which is sent after a widget is hidden.
Definition: qevent.h:656
The QKeySequence class encapsulates a key sequence as used by shortcuts.
Definition: qkeysequence.h:71
bool isEmpty() const
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal.
Definition: qstring.h:84
const_reference at(qsizetype i) const noexcept
Definition: qlist.h:457
qsizetype removeAll(const AT &t)
Definition: qlist.h:590
qsizetype count() const noexcept
Definition: qlist.h:415
void append(parameter_type t)
Definition: qlist.h:469
The QMarginsF class defines the four margins of a rectangle.
Definition: qmargins.h:301
constexpr bool isNull() const noexcept
Definition: qmargins.h:388
The QMutex class provides access serialization between threads.
Definition: qmutex.h:285
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes.
Definition: qmutex.h:317
QString objectName
the name of this object
Definition: qobject.h:129
virtual bool event(QEvent *event)
Definition: qobject.cpp:1329
void deleteLater()
Definition: qobject.cpp:2319
The QPainter class performs low-level painting on widgets and other paint devices.
Definition: qpainter.h:82
void setClipRect(const QRectF &, Qt::ClipOperation op=Qt::ReplaceClip)
Definition: qpainter.cpp:2717
void restore()
Definition: qpainter.cpp:1611
void save()
Definition: qpainter.cpp:1577
void setFont(const QFont &f)
Definition: qpainter.cpp:3866
void drawPixmap(const QRectF &targetRect, const QPixmap &pixmap, const QRectF &sourceRect)
Definition: qpainter.cpp:4883
void fillPath(const QPainterPath &path, const QBrush &brush)
Definition: qpainter.cpp:3127
void translate(const QPointF &offset)
Definition: qpainter.cpp:2993
void fillRect(const QRectF &, const QBrush &)
Definition: qpainter.cpp:6644
void setClipRegion(const QRegion &, Qt::ClipOperation op=Qt::ReplaceClip)
Definition: qpainter.cpp:2826
The QPainterPath class provides a container for painting operations, enabling graphical shapes to be ...
Definition: qpainterpath.h:65
void addRect(const QRectF &rect)
The QPalette class contains color groups for each widget state.
Definition: qpalette.h:55
void setCurrentColorGroup(ColorGroup cg)
Definition: qpalette.h:99
ResolveMask resolveMask() const
Definition: qpalette.cpp:956
@ Inactive
Definition: qpalette.h:84
@ Normal
Definition: qpalette.h:84
@ Active
Definition: qpalette.h:84
@ Disabled
Definition: qpalette.h:84
QPalette resolve(const QPalette &other) const
Definition: qpalette.cpp:928
The QPixmap class is an off-screen image representation that can be used as a paint device.
Definition: qpixmap.h:63
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:242
constexpr qreal x() const noexcept
Definition: qpoint.h:361
constexpr qreal y() const noexcept
Definition: qpoint.h:366
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:52
The QRectF class defines a finite rectangle in the plane using floating point precision.
Definition: qrect.h:511
constexpr void moveTopLeft(const QPointF &p) noexcept
Definition: qrect.h:723
constexpr QRectF adjusted(qreal x1, qreal y1, qreal x2, qreal y2) const noexcept
Definition: qrect.h:822
constexpr void setSize(const QSizeF &s) noexcept
Definition: qrect.h:833
constexpr QPointF topLeft() const noexcept
Definition: qrect.h:538
constexpr QSizeF size() const noexcept
Definition: qrect.h:744
constexpr QRect toRect() const noexcept
Definition: qrect.h:866
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:59
constexpr void adjust(int x1, int y1, int x2, int y2) noexcept
Definition: qrect.h:400
bool contains(const QRect &r, bool proper=false) const noexcept
Definition: qrect.cpp:887
constexpr void setHeight(int h) noexcept
Definition: qrect.h:411
T * data() const noexcept
Definition: qset.h:54
bool contains(const T &value) const
Definition: qset.h:107
The QShowEvent class provides an event that is sent when a widget is shown.
Definition: qevent.h:647
The QSizeF class defines the size of a two-dimensional object using floating point precision.
Definition: qsize.h:235
constexpr bool isValid() const noexcept
Definition: qsize.h:346
constexpr qreal width() const noexcept
Definition: qsize.h:349
constexpr qreal height() const noexcept
Definition: qsize.h:352
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:55
constexpr int height() const noexcept
Definition: qsize.h:160
constexpr int width() const noexcept
Definition: qsize.h:157
The QString class provides a Unicode character string.
Definition: qstring.h:388
static QString fromLatin1(QByteArrayView ba)
Definition: qstring.cpp:5488
QString arg(qlonglong a, int fieldwidth=0, int base=10, QChar fillChar=QLatin1Char(' ')) const
Definition: qstring.cpp:8318
static QString number(int, int base=10)
Definition: qstring.cpp:7538
The QStyleHintReturnMask class provides style hints that return a QRegion.
Definition: qstyleoption.h:740
The QStyle class is an abstract base class that encapsulates the look and feel of a GUI.
Definition: qstyle.h:65
@ State_Window
Definition: qstyle.h:120
@ State_MouseOver
Definition: qstyle.h:116
@ State_Sunken
Definition: qstyle.h:105
@ State_HasFocus
Definition: qstyle.h:111
@ State_Active
Definition: qstyle.h:119
@ State_Enabled
Definition: qstyle.h:103
@ State_None
Definition: qstyle.h:102
virtual void drawComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, QPainter *p, const QWidget *widget=nullptr) const =0
@ SH_TitleBar_NoBorder
Definition: qstyle.h:645
@ SH_WindowFrame_Mask
Definition: qstyle.h:674
virtual int styleHint(StyleHint stylehint, const QStyleOption *opt=nullptr, const QWidget *widget=nullptr, QStyleHintReturn *returnData=nullptr) const =0
@ PM_MdiSubWindowFrameWidth
Definition: qstyle.h:507
@ CC_TitleBar
Definition: qstyle.h:373
@ PE_FrameWindow
Definition: qstyle.h:148
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
Definition: qstyleoption.h:127
The QStyleOptionGraphicsItem class is used to describe the parameters needed to draw a QGraphicsItem.
Definition: qstyleoption.h:684
The QStyleOption class stores the parameters used by QStyle functions.
Definition: qstyleoption.h:75
QStyle::State state
Definition: qstyleoption.h:95
QPalette palette
Definition: qstyleoption.h:99
the position of the selected tab in relation to this tab
Definition: qstyleoption.h:630
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:95
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:133
QOpenGLWidget * widget
[1]
double e
rect
[4]
direction
palette
short next
Definition: keywords.cpp:454
WidgetAttribute
Definition: qnamespace.h:307
@ WA_SetLayoutDirection
Definition: qnamespace.h:348
@ WA_SetPalette
Definition: qnamespace.h:328
@ WA_RightToLeft
Definition: qnamespace.h:347
@ WA_Resized
Definition: qnamespace.h:333
@ WA_SetStyle
Definition: qnamespace.h:381
@ WA_NoSystemBackground
Definition: qnamespace.h:316
@ WA_SetFont
Definition: qnamespace.h:329
@ WA_OpaquePaintEvent
Definition: qnamespace.h:312
@ WA_DeleteOnClose
Definition: qnamespace.h:346
@ IntersectClip
Definition: qnamespace.h:1333
LayoutDirection
Definition: qnamespace.h:1462
@ LeftToRight
Definition: qnamespace.h:1463
@ RightToLeft
Definition: qnamespace.h:1464
FocusPolicy
Definition: qnamespace.h:131
@ NoFocus
Definition: qnamespace.h:132
WindowFrameSection
Definition: qnamespace.h:1597
@ LeftSection
Definition: qnamespace.h:1599
@ NoSection
Definition: qnamespace.h:1598
@ BottomSection
Definition: qnamespace.h:1605
@ TopRightSection
Definition: qnamespace.h:1602
@ TopLeftSection
Definition: qnamespace.h:1600
@ TitleBarArea
Definition: qnamespace.h:1607
@ BottomLeftSection
Definition: qnamespace.h:1606
@ BottomRightSection
Definition: qnamespace.h:1604
@ TopSection
Definition: qnamespace.h:1601
@ RightSection
Definition: qnamespace.h:1603
WindowType
Definition: qnamespace.h:230
@ FramelessWindowHint
Definition: qnamespace.h:250
@ ToolTip
Definition: qnamespace.h:238
@ Popup
Definition: qnamespace.h:236
@ WindowType_Mask
Definition: qnamespace.h:245
@ Window
Definition: qnamespace.h:232
SizeHint
Definition: qnamespace.h:1589
@ MaximumSize
Definition: qnamespace.h:1592
@ PreferredSize
Definition: qnamespace.h:1591
@ MinimumSize
Definition: qnamespace.h:1590
@ BacktabFocusReason
Definition: qnamespace.h:1363
@ TabFocusReason
Definition: qnamespace.h:1362
ShortcutContext
Definition: qnamespace.h:1313
action
Definition: devices.py:78
#define QString()
Definition: parse-defines.h:51
#define Q_FALLTHROUGH()
#define qApp
EGLOutputLayerEXT EGLint EGLAttrib value
EGLOutputLayerEXT EGLint attribute
QT_END_INCLUDE_NAMESPACE typedef double qreal
Definition: qglobal.h:341
unsigned int uint
Definition: qglobal.h:334
#define Q_GLOBAL_STATIC(TYPE, NAME,...)
#define qDebug
[1]
Definition: qlogging.h:177
#define qWarning
Definition: qlogging.h:179
GLint GLint GLint GLint GLint x
[0]
GLboolean r
[2]
GLfloat GLfloat GLfloat w
[0]
GLint GLsizei GLsizei height
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLuint index
[2]
GLdouble GLdouble GLdouble GLdouble top
GLdouble GLdouble right
GLenum GLenum GLsizei const GLuint GLboolean enabled
GLint left
GLint GLint bottom
GLint first
GLint GLint GLint GLint GLint GLint GLint GLbitfield mask
GLint y
struct _cl_event * event
Definition: qopenglext.h:2998
GLsizei const GLchar *const * path
Definition: qopenglext.h:4283
GLdouble s
[6]
Definition: qopenglext.h:235
GLuint GLenum option
Definition: qopenglext.h:5929
#define Q_ASSERT(cond)
Definition: qrandom.cpp:84
QScopeGuard< typename std::decay< F >::type > qScopeGuard(F &&f)
[qScopeGuard]
Definition: qscopeguard.h:93
bool qWidgetShortcutContextMatcher(QObject *object, Qt::ShortcutContext context)
#define emit
Definition: qtmetamacros.h:85
#define QWIDGETSIZE_MAX
Definition: qwidget.h:951
const char className[16]
[1]
Definition: qwizard.cpp:135
Q_UNUSED(salary)
[21]
obj metaObject() -> className()
QObject::connect nullptr
QString title
[35]
QRect r1(100, 200, 11, 16)
[0]
QGraphicsScene scene
[0]
QGraphicsItem * item
rect setPos(100, 100)
QList< QTreeWidgetItem * > items
app setAttribute(Qt::AA_DontShowIconsInMenus)
QPainter painter(this)
[7]
QSizePolicy policy
QNetworkProxy proxy
[0]
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent