Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qgraphicswidget.cpp
Go to the documentation of this file.
1// Copyright (C) 2021 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#include "qglobal.h"
5
6#include "qgraphicswidget.h"
7#include "qgraphicswidget_p.h"
8#include "qgraphicslayout.h"
9#include "qgraphicslayout_p.h"
10#include "qgraphicsscene.h"
11#include "qgraphicssceneevent.h"
12
13#ifndef QT_NO_ACTION
14#include <private/qaction_p.h>
15#endif
16#include <private/qapplication_p.h>
17#include <private/qgraphicsscene_p.h>
18#ifndef QT_NO_SHORTCUT
19#include <private/qshortcutmap_p.h>
20#endif
21#include <QtCore/qmutex.h>
22#include <QtCore/QScopeGuard>
23#include <QtWidgets/qapplication.h>
24#include <QtWidgets/qgraphicsview.h>
25#include <QtWidgets/qgraphicsproxywidget.h>
26#include <QtGui/qpalette.h>
27#include <QtGui/qpainterpath.h>
28#include <QtWidgets/qstyleoption.h>
29
30#include <qdebug.h>
31
33
34using namespace Qt::StringLiterals;
35
142QGraphicsWidget::QGraphicsWidget(QGraphicsItem *parent, Qt::WindowFlags wFlags)
144{
145 Q_D(QGraphicsWidget);
146 d->init(parent, wFlags);
147}
148
156{
157 Q_D(QGraphicsWidget);
158 d->init(parent, wFlags);
159}
160
161/*
162 \internal
163 \class QGraphicsWidgetStyles
164
165 We use this thread-safe class to maintain a hash of styles for widgets
166 styles. Note that QApplication::style() itself isn't thread-safe, QStyle
167 isn't thread-safe, and we don't have a thread-safe factory for creating
168 the default style, nor cloning a style.
169*/
171{
172public:
174 {
175 QMutexLocker locker(&mutex);
176 return styles.value(widget, 0);
177 }
178
180 {
181 QMutexLocker locker(&mutex);
182 if (style)
183 styles[widget] = style;
184 else
185 styles.remove(widget);
186 }
187
188private:
189 QHash<const QGraphicsWidget *, QStyle *> styles;
190 mutable QMutex mutex;
191};
193
194
198{
199 Q_D(QGraphicsWidget);
200#ifndef QT_NO_ACTION
201 // Remove all actions from this widget
202 for (auto action : std::as_const(d->actions)) {
203 QActionPrivate *apriv = action->d_func();
204 apriv->associatedObjects.removeAll(this);
205 }
206 d->actions.clear();
207#endif
208
209 if (QGraphicsScene *scn = scene()) {
210 QGraphicsScenePrivate *sceneD = scn->d_func();
211 if (sceneD->tabFocusFirst == this)
212 sceneD->tabFocusFirst = (d->focusNext == this ? nullptr : d->focusNext);
213 }
214 d->focusPrev->d_func()->focusNext = d->focusNext;
215 d->focusNext->d_func()->focusPrev = d->focusPrev;
216
217 // Play it really safe
218 d->focusNext = this;
219 d->focusPrev = this;
220
221 clearFocus();
222
223 //we check if we have a layout previously
224 if (d->layout) {
225 QGraphicsLayout *temp = d->layout;
226 const auto items = childItems();
227 for (QGraphicsItem *item : items) {
228 // In case of a custom layout which doesn't remove and delete items, we ensure that
229 // the parent layout item does not point to the deleted layout. This code is here to
230 // avoid regression from 4.4 to 4.5, because according to 4.5 docs it is not really needed.
231 if (item->isWidget()) {
232 QGraphicsWidget *widget = static_cast<QGraphicsWidget *>(item);
233 if (widget->parentLayoutItem() == d->layout)
234 widget->setParentLayoutItem(nullptr);
235 }
236 }
237 d->layout = nullptr;
238 delete temp;
239 }
240
241 // Remove this graphics widget from widgetStyles
242 widgetStyles()->setStyleForWidget(this, nullptr);
243
244 // Unset the parent here, when we're still a QGraphicsWidget.
245 // It is otherwise done in ~QGraphicsItem() where we'd be
246 // calling QGraphicsWidget members on an ex-QGraphicsWidget object
247 setParentItem(nullptr);
248}
249
277
282
320{
321 QGraphicsWidgetPrivate *wd = QGraphicsWidget::d_func();
322 // Package relayout of children in a scope guard so we can just return early
323 // when this widget's geometry is sorted out.
324 const auto relayoutChildren = qScopeGuard([this, wd]() {
326 if (QGraphicsLayout *lay = wd->layout) {
327 if (!lay->isActivated()) {
328 QEvent layoutRequest(QEvent::LayoutRequest);
329 QCoreApplication::sendEvent(this, &layoutRequest);
330 }
331 }
332 }
333 });
334
336 QRectF newGeom;
337 QPointF oldPos = d->geom.topLeft();
338 if (!wd->inSetPos) {
340 newGeom = rect;
341 newGeom.setSize(rect.size().expandedTo(effectiveSizeHint(Qt::MinimumSize))
342 .boundedTo(effectiveSizeHint(Qt::MaximumSize)));
343
344 if (newGeom == d->geom)
345 return;
346
347 // setPos triggers ItemPositionChange, which can adjust position
348 wd->inSetGeometry = 1;
349 setPos(newGeom.topLeft());
350 wd->inSetGeometry = 0;
351 newGeom.moveTopLeft(pos());
352
353 if (newGeom == d->geom)
354 return;
355
356 // Update and prepare to change the geometry (remove from index) if
357 // the size has changed.
358 if (wd->scene && rect.topLeft() == d->geom.topLeft())
359 prepareGeometryChange();
360 }
361
362 // Update the layout item geometry
363 if (oldPos != pos()) {
364 // Send move event.
366 event.setOldPos(oldPos);
367 event.setNewPos(pos());
369 if (wd->inSetPos) {
370 // Set the new position:
371 d->geom.moveTopLeft(pos());
372 emit geometryChanged();
373 return;
374 }
375 }
376
377 QSizeF oldSize = size();
379 // Send resize event, if appropriate:
380 if (newGeom.size() != oldSize) {
381 if (oldSize.width() != newGeom.size().width())
382 emit widthChanged();
383 if (oldSize.height() != newGeom.size().height())
384 emit heightChanged();
385 QGraphicsLayout *lay = wd->layout;
386 if (!QGraphicsLayout::instantInvalidatePropagation() || !lay || lay->isActivated()) {
388 re.setOldSize(oldSize);
389 re.setNewSize(newGeom.size());
391 }
392 }
393
394 emit geometryChanged();
395}
396
454{
455 Q_D(QGraphicsWidget);
456
457 if (!d->margins && margins.isNull())
458 return;
459 d->ensureMargins();
460 if (*d->margins == margins)
461 return;
462
463 *d->margins = margins;
464
465 if (QGraphicsLayout *l = d->layout)
466 l->invalidate();
467 else
469
472}
473
484
493{
494 Q_D(const QGraphicsWidget);
495 if (left || top || right || bottom)
496 d->ensureMargins();
497 if (left)
498 *left = d->margins->left();
499 if (top)
500 *top = d->margins->top();
501 if (right)
502 *right = d->margins->right();
503 if (bottom)
504 *bottom = d->margins->bottom();
505}
506
519{
520 Q_D(QGraphicsWidget);
521
522 if (!d->windowFrameMargins && margins.isNull())
523 return;
524 d->ensureWindowFrameMargins();
525 const bool unchanged = *d->windowFrameMargins == margins;
526 if (d->setWindowFrameMargins && unchanged)
527 return;
528 if (!unchanged)
530 *d->windowFrameMargins = margins;
531 d->setWindowFrameMargins = true;
532}
533
543
552{
553 Q_D(const QGraphicsWidget);
554 if (left || top || right || bottom)
555 d->ensureWindowFrameMargins();
556 if (left)
557 *left = d->windowFrameMargins->left();
558 if (top)
559 *top = d->windowFrameMargins->top();
560 if (right)
561 *right = d->windowFrameMargins->right();
562 if (bottom)
563 *bottom = d->windowFrameMargins->bottom();
564}
565
572{
573 Q_D(QGraphicsWidget);
574 if ((d->windowFlags & Qt::Window) && (d->windowFlags & Qt::WindowType_Mask) != Qt::Popup &&
575 (d->windowFlags & Qt::WindowType_Mask) != Qt::ToolTip && !(d->windowFlags & Qt::FramelessWindowHint)) {
577 d->initStyleOptionTitleBar(&bar);
578 QStyle *style = this->style();
580 qreal titleBarHeight = d->titleBarHeight(bar);
581 setWindowFrameMargins(margin, titleBarHeight, margin, margin);
582 } else {
583 setWindowFrameMargins(0, 0, 0, 0);
584 }
585 d->setWindowFrameMargins = false;
586}
587
595{
596 Q_D(const QGraphicsWidget);
597 return d->windowFrameMargins
598 ? geometry().adjusted(-d->windowFrameMargins->left(), -d->windowFrameMargins->top(),
599 d->windowFrameMargins->right(), d->windowFrameMargins->bottom())
600 : geometry();
601}
602
609{
610 Q_D(const QGraphicsWidget);
611 return d->windowFrameMargins
612 ? rect().adjusted(-d->windowFrameMargins->left(), -d->windowFrameMargins->top(),
613 d->windowFrameMargins->right(), d->windowFrameMargins->bottom())
614 : rect();
615}
616
660{
662
663 option->state = QStyle::State_None;
664 if (isEnabled())
666 if (hasFocus())
668 // if (window->testAttribute(Qt::WA_KeyboardFocusChange)) // ### Window
669 // option->state |= QStyle::State_KeyboardFocusChange;
670 if (isUnderMouse())
672 if (QGraphicsWidget *w = window()) {
673 if (w->isActiveWindow())
675 }
676 if (isWindow())
678 /*
679 ###
680#ifdef QT_KEYPAD_NAVIGATION
681 if (widget->hasEditFocus())
682 state |= QStyle::State_HasEditFocus;
683#endif
684 */
685 option->direction = layoutDirection();
686 option->rect = rect().toRect(); // ### truncation!
687 option->palette = palette();
688 if (!isEnabled()) {
689 option->palette.setCurrentColorGroup(QPalette::Disabled);
690 } else if (isActiveWindow()) {
691 option->palette.setCurrentColorGroup(QPalette::Active);
692 } else {
693 option->palette.setCurrentColorGroup(QPalette::Inactive);
694 }
695 option->fontMetrics = QFontMetrics(font());
696 option->styleObject = const_cast<QGraphicsWidget *>(this);
697}
698
703{
704 Q_D(const QGraphicsWidget);
705 QSizeF sh;
706 if (d->layout) {
707 QSizeF marginSize(0,0);
708 if (d->margins) {
709 marginSize = QSizeF(d->margins->left() + d->margins->right(),
710 d->margins->top() + d->margins->bottom());
711 }
712 sh = d->layout->effectiveSizeHint(which, constraint - marginSize);
713 sh += marginSize;
714 } else {
715 switch (which) {
716 case Qt::MinimumSize:
717 sh = QSizeF(0, 0);
718 break;
720 sh = QSizeF(50, 50); //rather arbitrary
721 break;
722 case Qt::MaximumSize:
724 break;
725 default:
726 qWarning("QGraphicsWidget::sizeHint(): Don't know how to handle the value of 'which'");
727 break;
728 }
729 }
730 return sh;
731}
732
767{
768 Q_D(const QGraphicsWidget);
769 return d->layout;
770}
771
792{
793 Q_D(QGraphicsWidget);
794 if (d->layout == l)
795 return;
796 d->setLayout_helper(l);
797 if (!l)
798 return;
799
800 // Prevent assigning a layout that is already assigned to another widget.
801 QGraphicsLayoutItem *oldParent = l->parentLayoutItem();
802 if (oldParent && oldParent != this) {
803 qWarning("QGraphicsWidget::setLayout: Attempting to set a layout on %s"
804 " \"%s\", when the layout already has a parent",
806 return;
807 }
808
809 // Install and activate the layout.
810 l->setParentLayoutItem(this);
811 l->d_func()->reparentChildItems(this);
812 l->invalidate();
814}
815
825{
827 // What if sz is not valid?!
828 if (sz.isValid())
829 resize(sz);
830}
831
869{
870 Q_D(QGraphicsWidget);
872 d->resolveLayoutDirection();
873}
874
884{
885 if (QStyle *style = widgetStyles()->styleForWidget(this))
886 return style;
887 // ### This is not thread-safe. QApplication::style() is not thread-safe.
888 return scene() ? scene()->style() : QApplication::style();
889}
890
905{
907 widgetStyles()->setStyleForWidget(this, style);
908
909 // Deliver StyleChange to the widget itself (doesn't propagate).
912}
913
937{
938 Q_D(const QGraphicsWidget);
939 QFont fnt = d->font;
940 fnt.setResolveMask(fnt.resolveMask() | d->inheritedFontResolveMask);
941 return fnt;
942}
944{
945 Q_D(QGraphicsWidget);
947
948 QFont naturalFont = d->naturalWidgetFont();
949 QFont resolvedFont = font.resolve(naturalFont);
950 d->setFont_helper(resolvedFont);
951}
952
979{
980 Q_D(const QGraphicsWidget);
981 return d->palette;
982}
984{
985 Q_D(QGraphicsWidget);
987
988 QPalette naturalPalette = d->naturalWidgetPalette();
989 QPalette resolvedPalette = palette.resolve(naturalPalette);
990 d->setPalette_helper(resolvedPalette);
991}
992
1010{
1011 Q_D(const QGraphicsWidget);
1012 return d->autoFillBackground;
1013}
1015{
1016 Q_D(QGraphicsWidget);
1017 if (d->autoFillBackground != enabled) {
1018 d->autoFillBackground = enabled;
1019 update();
1020 }
1021}
1022
1033{
1036
1037 if (parentItem && parentItem->isLayout()) {
1039 static_cast<QGraphicsLayout *>(parentItem)->invalidate();
1040 } else {
1041 parentItem->updateGeometry();
1042 }
1043 } else {
1044 if (parentItem) {
1045 // This is for custom layouting
1046 QGraphicsWidget *parentWid = parentWidget(); //###
1047 if (parentWid->isVisible())
1049 } else {
1057 }
1059 bool wasResized = testAttribute(Qt::WA_Resized);
1060 resize(size()); // this will restrict the size
1061 setAttribute(Qt::WA_Resized, wasResized);
1062 }
1063 }
1064}
1065
1087{
1088 Q_D(QGraphicsWidget);
1089 switch (change) {
1090 case ItemEnabledHasChanged: {
1091 // Send EnabledChange after the enabled state has changed.
1094 break;
1095 }
1096 case ItemVisibleChange:
1097 if (value.toBool()) {
1098 // Send Show event before the item has been shown.
1101 bool resized = testAttribute(Qt::WA_Resized);
1102 if (!resized) {
1103 adjustSize();
1105 }
1106 }
1107
1108 // layout size hint only changes if an item changes from/to explicitly hidden state
1109 if (value.toBool() || d->explicitlyHidden)
1111 break;
1113 if (!value.toBool()) {
1114 // Send Hide event after the item has been hidden.
1117 }
1118 break;
1120 d->setGeometryFromSetPos();
1121 break;
1122 case ItemParentChange: {
1123 // Deliver ParentAboutToChange.
1126 break;
1127 }
1128 case ItemParentHasChanged: {
1129 // Deliver ParentChange.
1132 break;
1133 }
1134 case ItemCursorHasChanged: {
1135 // Deliver CursorChange.
1138 break;
1139 }
1140 case ItemToolTipHasChanged: {
1141 // Deliver ToolTipChange.
1144 break;
1145 }
1146 default:
1147 break;
1148 }
1149 return QGraphicsItem::itemChange(change, value);
1150}
1151
1179{
1180 Q_UNUSED(propertyName);
1181 return value;
1182}
1183
1199
1214{
1215 Q_D(QGraphicsWidget);
1216 switch (event->type()) {
1218 d->windowFrameMousePressEvent(static_cast<QGraphicsSceneMouseEvent *>(event));
1219 break;
1221 d->ensureWindowData();
1222 if (d->windowData->grabbedSection != Qt::NoSection) {
1223 d->windowFrameMouseMoveEvent(static_cast<QGraphicsSceneMouseEvent *>(event));
1224 event->accept();
1225 }
1226 break;
1228 d->windowFrameMouseReleaseEvent(static_cast<QGraphicsSceneMouseEvent *>(event));
1229 break;
1231 d->windowFrameHoverMoveEvent(static_cast<QGraphicsSceneHoverEvent *>(event));
1232 break;
1234 d->windowFrameHoverLeaveEvent(static_cast<QGraphicsSceneHoverEvent *>(event));
1235 break;
1236 default:
1237 break;
1238 }
1239 return event->isAccepted();
1240}
1241
1261{
1262 Q_D(const QGraphicsWidget);
1263
1264 const QRectF r = windowFrameRect();
1265 if (!r.contains(pos))
1266 return Qt::NoSection;
1267
1268 const qreal left = r.left();
1269 const qreal top = r.top();
1270 const qreal right = r.right();
1271 const qreal bottom = r.bottom();
1272 const qreal x = pos.x();
1273 const qreal y = pos.y();
1274
1275 const qreal cornerMargin = 20;
1276 //### Not sure of this one, it should be the same value for all edges.
1277 const qreal windowFrameWidth = d->windowFrameMargins
1278 ? d->windowFrameMargins->left() : 0;
1279
1281 if (x <= left + cornerMargin) {
1282 if (y <= top + windowFrameWidth || (x <= left + windowFrameWidth && y <= top + cornerMargin)) {
1284 } else if (y >= bottom - windowFrameWidth || (x <= left + windowFrameWidth && y >= bottom - cornerMargin)) {
1286 } else if (x <= left + windowFrameWidth) {
1288 }
1289 } else if (x >= right - cornerMargin) {
1290 if (y <= top + windowFrameWidth || (x >= right - windowFrameWidth && y <= top + cornerMargin)) {
1292 } else if (y >= bottom - windowFrameWidth || (x >= right - windowFrameWidth && y >= bottom - cornerMargin)) {
1294 } else if (x >= right - windowFrameWidth) {
1296 }
1297 } else if (y <= top + windowFrameWidth) {
1298 s = Qt::TopSection;
1299 } else if (y >= bottom - windowFrameWidth) {
1301 }
1302 if (s == Qt::NoSection) {
1303 QRectF r1 = r;
1304 r1.setHeight(d->windowFrameMargins
1305 ? d->windowFrameMargins->top() : 0);
1306 if (r1.contains(pos))
1308 }
1309 return s;
1310}
1311
1350{
1351 Q_D(QGraphicsWidget);
1352 // Forward the event to the layout first.
1353 if (d->layout)
1354 d->layout->widgetEvent(event);
1355
1356 // Handle the event itself.
1357 switch (event->type()) {
1359 moveEvent(static_cast<QGraphicsSceneMoveEvent *>(event));
1360 break;
1363 break;
1364 case QEvent::Show:
1365 showEvent(static_cast<QShowEvent *>(event));
1366 break;
1367 case QEvent::Hide:
1368 hideEvent(static_cast<QHideEvent *>(event));
1369 break;
1370 case QEvent::Polish:
1371 polishEvent();
1372 d->polished = true;
1373 if (!d->font.isCopyOf(QApplication::font()))
1374 d->updateFont(d->font);
1375 break;
1378 update();
1379 break;
1381 if (isVisible()) {
1382 event->accept();
1383 update();
1384 }
1385 break;
1386 // Taken from QWidget::event
1389 case QEvent::FontChange:
1396 break;
1397 case QEvent::Close:
1399 break;
1400 case QEvent::GrabMouse:
1402 break;
1405 break;
1408 break;
1411 break;
1413 if (d->hasDecoration() && windowFrameEvent(event))
1414 return true;
1415 break;
1419 d->ensureWindowData();
1420 if (d->hasDecoration() && d->windowData->grabbedSection != Qt::NoSection)
1421 return windowFrameEvent(event);
1422 break;
1426 if (d->hasDecoration()) {
1428 // Filter out hover events if they were sent to us only because of the
1429 // decoration (special case in QGraphicsScenePrivate::dispatchHoverEvent).
1430 if (!acceptHoverEvents())
1431 return true;
1432 }
1433 break;
1434 default:
1435 break;
1436 }
1437 return QObject::event(event);
1438}
1439
1451{
1452 Q_D(QGraphicsWidget);
1453 switch (event->type()) {
1455 // ### Don't unset if the margins are explicitly set.
1457 if (d->layout)
1458 d->layout->invalidate();
1459 Q_FALLTHROUGH();
1460 case QEvent::FontChange:
1461 update();
1463 break;
1465 update();
1466 break;
1468 d->resolveFont(d->inheritedFontResolveMask);
1469 d->resolvePalette(d->inheritedPaletteResolveMask);
1470 break;
1471 default:
1472 break;
1473 }
1474}
1475
1484{
1485 event->accept();
1486}
1487
1497
1518{
1519 Q_D(QGraphicsWidget);
1520 // Let the parent's focusNextPrevChild implementation decide what to do.
1521 QGraphicsWidget *parent = nullptr;
1522 if (!isWindow() && (parent = parentWidget()))
1523 return parent->focusNextPrevChild(next);
1524 if (!d->scene)
1525 return false;
1526 if (d->scene->focusNextPrevChild(next))
1527 return true;
1528 if (isWindow()) {
1530 if (hasFocus())
1531 return true;
1532 }
1533 return false;
1534}
1535
1545
1559{
1561 // is hidden.
1562 Q_UNUSED(event);
1563}
1564
1581{
1582 // ### Last position is always == current position
1583 Q_UNUSED(event);
1584}
1585
1597
1618
1635
1643
1651
1662
1673
1684
1695
1705
1723Qt::WindowFlags QGraphicsWidget::windowFlags() const
1724{
1725 Q_D(const QGraphicsWidget);
1726 return d->windowFlags;
1727}
1728void QGraphicsWidget::setWindowFlags(Qt::WindowFlags wFlags)
1729{
1730 Q_D(QGraphicsWidget);
1731 if (d->windowFlags == wFlags)
1732 return;
1733 bool wasPopup = (d->windowFlags & Qt::WindowType_Mask) == Qt::Popup;
1734
1735 d->adjustWindowFlags(&wFlags);
1736 d->windowFlags = wFlags;
1737 if (!d->setWindowFrameMargins)
1739
1740 setFlag(ItemIsPanel, d->windowFlags & Qt::Window);
1741
1742 bool isPopup = (d->windowFlags & Qt::WindowType_Mask) == Qt::Popup;
1743 if (d->scene && isVisible() && wasPopup != isPopup) {
1744 // Popup state changed; update implicit mouse grab.
1745 if (!isPopup)
1746 d->scene->d_func()->removePopup(this);
1747 else
1748 d->scene->d_func()->addPopup(this);
1749 }
1750
1751 if (d->scene && d->scene->d_func()->allItemsIgnoreHoverEvents && d->hasDecoration()) {
1752 d->scene->d_func()->allItemsIgnoreHoverEvents = false;
1753 d->scene->d_func()->enableMouseTrackingOnViews();
1754 }
1755}
1756
1768{
1769 return isActive();
1770}
1771
1782{
1783 Q_D(QGraphicsWidget);
1784 d->ensureWindowData();
1785 d->windowData->windowTitle = title;
1786}
1788{
1789 Q_D(const QGraphicsWidget);
1790 return d->windowData ? d->windowData->windowTitle : QString();
1791}
1792
1814{
1815 Q_D(const QGraphicsWidget);
1816 return d->focusPolicy;
1817}
1819{
1820 Q_D(QGraphicsWidget);
1821 if (d->focusPolicy == policy)
1822 return;
1823 d->focusPolicy = policy;
1824 if (hasFocus() && policy == Qt::NoFocus)
1825 clearFocus();
1827}
1828
1837{
1838 Q_D(const QGraphicsWidget);
1839 if (d->subFocusItem && d->subFocusItem->d_ptr->isWidget)
1840 return static_cast<QGraphicsWidget *>(d->subFocusItem);
1841 return nullptr;
1842}
1843
1844#ifndef QT_NO_SHORTCUT
1873{
1874 Q_ASSERT(qApp);
1875 if (sequence.isEmpty())
1876 return 0;
1877 // ### setAttribute(Qt::WA_GrabbedShortcut);
1878 return QGuiApplicationPrivate::instance()->shortcutMap.addShortcut(this, sequence, context, qWidgetShortcutContextMatcher);
1879}
1880
1899{
1900 Q_ASSERT(qApp);
1901 if (id)
1902 QGuiApplicationPrivate::instance()->shortcutMap.removeShortcut(id, this, 0);
1903}
1904
1920{
1921 Q_ASSERT(qApp);
1922 if (id)
1923 QGuiApplicationPrivate::instance()->shortcutMap.setShortcutEnabled(enabled, id, this, 0);
1924}
1925
1935{
1936 Q_ASSERT(qApp);
1937 if (id)
1938 QGuiApplicationPrivate::instance()->shortcutMap.setShortcutAutoRepeat(enabled, id, this, 0);
1939}
1940#endif
1941
1942#ifndef QT_NO_ACTION
1958{
1959 insertAction(nullptr, action);
1960}
1961
1969void QGraphicsWidget::addActions(const QList<QAction *> &actions)
1970{
1971 for (int i = 0; i < actions.size(); ++i)
1972 insertAction(nullptr, actions.at(i));
1973}
1974
1988{
1989 if (!action) {
1990 qWarning("QWidget::insertAction: Attempt to insert null action");
1991 return;
1992 }
1993
1994 Q_D(QGraphicsWidget);
1995 int index = d->actions.indexOf(action);
1996 if (index != -1)
1997 d->actions.removeAt(index);
1998
1999 int pos = d->actions.indexOf(before);
2000 if (pos < 0) {
2001 before = nullptr;
2002 pos = d->actions.size();
2003 }
2004 d->actions.insert(pos, action);
2005
2006 if (index == -1) {
2007 QActionPrivate *apriv = action->d_func();
2008 apriv->associatedObjects.append(this);
2009 }
2010
2011 QActionEvent e(QEvent::ActionAdded, action, before);
2013}
2014
2026void QGraphicsWidget::insertActions(QAction *before, const QList<QAction *> &actions)
2027{
2028 for (int i = 0; i < actions.size(); ++i)
2029 insertAction(before, actions.at(i));
2030}
2031
2040{
2041 if (!action)
2042 return;
2043
2044 Q_D(QGraphicsWidget);
2045
2046 QActionPrivate *apriv = action->d_func();
2047 apriv->associatedObjects.removeAll(this);
2048
2049 if (d->actions.removeAll(action)) {
2052 }
2053}
2054
2063QList<QAction *> QGraphicsWidget::actions() const
2064{
2065 Q_D(const QGraphicsWidget);
2066 return d->actions;
2067}
2068#endif
2069
2095{
2096 if (!first && !second) {
2097 qWarning("QGraphicsWidget::setTabOrder(0, 0) is undefined");
2098 return;
2099 }
2100 if ((first && second) && first->scene() != second->scene()) {
2101 qWarning("QGraphicsWidget::setTabOrder: scenes %p and %p are different",
2102 first->scene(), second->scene());
2103 return;
2104 }
2105 QGraphicsScene *scene = first ? first->scene() : second->scene();
2106 if (!scene) {
2107 qWarning("QGraphicsWidget::setTabOrder: assigning tab order from/to the"
2108 " scene requires the item to be in a scene.");
2109 return;
2110 }
2111
2112 // If either first or second are 0, the scene's tabFocusFirst is updated
2113 // to point to the first item in the scene's focus chain. Then first or
2114 // second are set to point to tabFocusFirst.
2115 QGraphicsScenePrivate *sceneD = scene->d_func();
2116 if (!first) {
2117 sceneD->tabFocusFirst = second;
2118 return;
2119 }
2120 if (!second) {
2121 sceneD->tabFocusFirst = first->d_func()->focusNext;
2122 return;
2123 }
2124
2125 // Both first and second are != 0.
2126 QGraphicsWidget *firstFocusNext = first->d_func()->focusNext;
2127 if (firstFocusNext == second) {
2128 // Nothing to do.
2129 return;
2130 }
2131
2132 // Update the focus chain.
2133 QGraphicsWidget *secondFocusPrev = second->d_func()->focusPrev;
2134 QGraphicsWidget *secondFocusNext = second->d_func()->focusNext;
2135 firstFocusNext->d_func()->focusPrev = second;
2136 first->d_func()->focusNext = second;
2137 second->d_func()->focusNext = firstFocusNext;
2138 second->d_func()->focusPrev = first;
2139 secondFocusPrev->d_func()->focusNext = secondFocusNext;
2140 secondFocusNext->d_func()->focusPrev = secondFocusPrev;
2141
2142 Q_ASSERT(first->d_func()->focusNext->d_func()->focusPrev == first);
2143 Q_ASSERT(first->d_func()->focusPrev->d_func()->focusNext == first);
2144
2145 Q_ASSERT(second->d_func()->focusNext->d_func()->focusPrev == second);
2146 Q_ASSERT(second->d_func()->focusPrev->d_func()->focusNext == second);
2147
2148}
2149
2160{
2161 Q_D(QGraphicsWidget);
2162 // ### most flags require some immediate action
2163 // ### we might want to qWarn use of unsupported attributes
2164 // ### we might want to not use Qt::WidgetAttribute, but roll our own instead
2165 d->setAttribute(attribute, on);
2166}
2167
2175{
2176 Q_D(const QGraphicsWidget);
2177 return d->testAttribute(attribute);
2178}
2179
2192{
2193 return Type;
2194}
2195
2205
2218 QWidget *widget)
2219{
2222 QGraphicsProxyWidget *proxy = qobject_cast<QGraphicsProxyWidget *>(this);
2223 const bool embeddedWidgetFillsOwnBackground = proxy && proxy->widget();
2224
2225 if (rect().contains(option->exposedRect)) {
2226 if (fillBackground && !embeddedWidgetFillsOwnBackground)
2227 painter->fillRect(option->exposedRect, palette().window());
2228 return;
2229 }
2230
2231 Q_D(QGraphicsWidget);
2232
2235 bar.QStyleOption::operator=(*option);
2236 d->initStyleOptionTitleBar(&bar); // this clear flags in bar.state
2237 d->ensureWindowData();
2238 bar.state.setFlag(QStyle::State_MouseOver, d->windowData->buttonMouseOver);
2239 bar.state.setFlag(QStyle::State_Sunken, d->windowData->buttonSunken);
2240 bar.rect = windowFrameRect;
2241
2242 // translate painter to make the style happy
2243 const QPointF styleOrigin = this->windowFrameRect().topLeft();
2244 painter->translate(styleOrigin);
2245
2246#ifdef Q_OS_MAC
2247 const QSize pixmapSize = windowFrameRect.size();
2248 if (pixmapSize.width() <= 0 || pixmapSize.height() <= 0)
2249 return;
2250 QPainter *realPainter = painter;
2251 QPixmap pm(pixmapSize);
2252 painter = new QPainter(&pm);
2253#endif
2254
2255 // Fill background
2257 bool setMask = style()->styleHint(QStyle::SH_WindowFrame_Mask, &bar, widget, &mask) && !mask.region.isEmpty();
2258 bool hasBorder = !style()->styleHint(QStyle::SH_TitleBar_NoBorder, &bar, widget);
2259 int frameWidth = style()->pixelMetric(QStyle::PM_MdiSubWindowFrameWidth, &bar, widget);
2260 if (setMask) {
2261 painter->save();
2263 }
2264 if (fillBackground) {
2265 if (embeddedWidgetFillsOwnBackground) {
2266 // Don't fill the background twice.
2267 QPainterPath windowFrameBackground;
2268 windowFrameBackground.addRect(windowFrameRect);
2269 // Adjust with 0.5 to avoid border artifacts between
2270 // widget background and frame background.
2271 windowFrameBackground.addRect(rect().translated(-styleOrigin).adjusted(0.5, 0.5, -0.5, -0.5));
2272 painter->fillPath(windowFrameBackground, palette().window());
2273 } else {
2275 }
2276 }
2277
2278 // Draw title
2279 int height = (int)d->titleBarHeight(bar);
2280 bar.rect.setHeight(height);
2281 if (hasBorder) // Frame is painted by PE_FrameWindow
2282 bar.rect.adjust(frameWidth, frameWidth, -frameWidth, 0);
2283
2284 painter->save();
2285 painter->setFont(QApplication::font("QMdiSubWindowTitleBar"));
2287 painter->restore();
2288 if (setMask)
2289 painter->restore();
2290 // Draw window frame
2291 QStyleOptionFrame frameOptions;
2292 frameOptions.QStyleOption::operator=(*option);
2293 initStyleOption(&frameOptions);
2294 if (!hasBorder)
2296 frameOptions.state.setFlag(QStyle::State_HasFocus, hasFocus());
2297 bool isActive = isActiveWindow();
2298 frameOptions.state.setFlag(QStyle::State_Active, isActive);
2299
2300 frameOptions.palette.setCurrentColorGroup(isActive ? QPalette::Active : QPalette::Normal);
2301 frameOptions.rect = windowFrameRect;
2302 frameOptions.lineWidth = style()->pixelMetric(QStyle::PM_MdiSubWindowFrameWidth, nullptr, widget);
2303 frameOptions.midLineWidth = 1;
2305
2306#ifdef Q_OS_MAC
2307 realPainter->drawPixmap(QPoint(), pm);
2308 delete painter;
2309#endif
2310}
2311
2316{
2317 return windowFrameRect();
2318}
2319
2324{
2326 path.addRect(rect());
2327 return path;
2328}
2329
2342{
2345 if (!closeEvent.isAccepted()) {
2346 return false;
2347 }
2348 // hide
2349 if (isVisible()) {
2350 hide();
2351 }
2353 deleteLater();
2354 }
2355 return true;
2356}
2357
2358#if 0
2359void QGraphicsWidget::dumpFocusChain()
2360{
2361 qDebug("=========== Dumping focus chain ==============");
2362 int i = 0;
2363 QGraphicsWidget *next = this;
2364 QSet<QGraphicsWidget*> visited;
2365 do {
2366 if (!next) {
2367 qWarning("Found a focus chain that is not circular, (next == 0)");
2368 break;
2369 }
2370 qDebug() << i++ << QString::number(uint(next), 16) << next->className() << next->data(0) << QString::fromLatin1("focusItem:%1").arg(next->hasFocus() ? '1' : '0') << "next:"_L1 << next->d_func()->focusNext->data(0) << "prev:"_L1 << next->d_func()->focusPrev->data(0);
2371 if (visited.contains(next)) {
2372 qWarning("Already visited this node. However, I expected to dump until I found myself.");
2373 break;
2374 }
2375 visited << next;
2376 next = next->d_func()->focusNext;
2377 } while (next != this);
2378}
2379#endif
2380
2382
2383#include "moc_qgraphicswidget.cpp"
The QActionEvent class provides an event that is generated when a QAction is added,...
QObjectList associatedObjects
Definition qaction_p.h:67
The QAction class provides an abstraction for user commands that can be added to different user inter...
Definition qaction.h:30
QList< QObject * > associatedObjects() const
Definition qaction.cpp:505
static QStyle * style()
Returns the application's style object.
static QFont font()
Returns the default application font.
The QCloseEvent class contains parameters that describe a close event.
Definition qevent.h:562
static bool sendEvent(QObject *receiver, QEvent *event)
Sends event event directly to receiver receiver, using the notify() function.
static void postEvent(QObject *receiver, QEvent *event, int priority=Qt::NormalEventPriority)
\inmodule QtCore
Definition qcoreevent.h:45
@ GraphicsSceneMouseMove
Definition qcoreevent.h:189
@ ActionRemoved
Definition qcoreevent.h:153
@ ContentsRectChange
Definition qcoreevent.h:219
@ ParentChange
Definition qcoreevent.h:80
@ EnabledChange
Definition qcoreevent.h:134
@ GraphicsSceneMouseRelease
Definition qcoreevent.h:191
@ ActionAdded
Definition qcoreevent.h:152
@ LayoutDirectionChange
Definition qcoreevent.h:124
@ GraphicsSceneMousePress
Definition qcoreevent.h:190
@ StyleChange
Definition qcoreevent.h:136
@ GraphicsSceneMove
Definition qcoreevent.h:226
@ CursorChange
Definition qcoreevent.h:228
@ LayoutRequest
Definition qcoreevent.h:112
@ UngrabMouse
Definition qcoreevent.h:234
@ FontChange
Definition qcoreevent.h:133
@ StyleAnimationUpdate
Definition qcoreevent.h:272
@ ActivationChange
Definition qcoreevent.h:135
@ ToolTipChange
Definition qcoreevent.h:229
@ GraphicsSceneHoverLeave
Definition qcoreevent.h:196
@ ParentAboutToChange
Definition qcoreevent.h:81
@ WindowActivate
Definition qcoreevent.h:83
@ GraphicsSceneMouseDoubleClick
Definition qcoreevent.h:192
@ GraphicsSceneResize
Definition qcoreevent.h:225
@ PaletteChange
Definition qcoreevent.h:94
@ GraphicsSceneHoverEnter
Definition qcoreevent.h:194
@ UngrabKeyboard
Definition qcoreevent.h:236
@ GraphicsSceneHoverMove
Definition qcoreevent.h:195
@ GrabKeyboard
Definition qcoreevent.h:235
@ WindowDeactivate
Definition qcoreevent.h:84
@ GrabMouse
Definition qcoreevent.h:233
The QFocusEvent class contains event parameters for widget focus events.
Definition qevent.h:470
\reentrant \inmodule QtGui
\reentrant
Definition qfont.h:22
QFont resolve(const QFont &) const
Returns a new QFont that has attributes copied from other that have not been previously set on this f...
Definition qfont.cpp:1893
void setResolveMask(uint mask)
Definition qfont.h:313
uint resolveMask() const
Definition qfont.h:312
The QGraphicsItem class is the base class for all graphical items in a QGraphicsScene.
virtual bool contains(const QPointF &point) const
Returns true if this item contains point, which is in local coordinates; otherwise,...
bool isWidget() const
GraphicsItemChange
This enum describes the state changes that are notified by QGraphicsItem::itemChange().
friend class QGraphicsWidget
void update(const QRectF &rect=QRectF())
Schedules a redraw of the area covered by rect in this item.
QGraphicsWidget * parentWidget() const
virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value)
This virtual function is called by QGraphicsItem to notify custom items that some part of the item's ...
bool isWindow() const
void clearFocus()
Takes keyboard input focus from the item.
QGraphicsScene * scene() const
Returns the current scene for the item, or \nullptr if the item is not stored in a scene.
QGraphicsWidget * window() const
bool isEnabled() const
Returns true if the item is enabled; otherwise, false is returned.
bool acceptHoverEvents() const
bool hasFocus() const
Returns true if this item is active, and it or its \l{focusProxy()}{focus proxy} has keyboard input f...
bool isUnderMouse() const
void prepareGeometryChange()
Prepares the item for a geometry change.
void setFlag(GraphicsItemFlag flag, bool enabled=true)
If enabled is true, the item flag flag is enabled; otherwise, it is disabled.
virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
This event handler, for event event, can be reimplemented to receive hover leave events for this item...
QGraphicsItem * parentItem() const
Returns a pointer to this item's parent item.
bool isVisible() const
Returns true if the item is visible; otherwise, false is returned.
void hide()
Hides the item (items are visible by default).
void setFocus(Qt::FocusReason focusReason=Qt::OtherFocusReason)
Gives keyboard input focus to this item.
bool isActive() const
virtual bool sceneEvent(QEvent *event)
This virtual function receives events to this item.
The QGraphicsLayoutItem class can be inherited to allow your custom items to be managed by layouts.
QSizeF effectiveSizeHint(Qt::SizeHint which, const QSizeF &constraint=QSizeF()) const
Returns the effective size hint for this QGraphicsLayoutItem.
QScopedPointer< QGraphicsLayoutItemPrivate > d_ptr
virtual void updateGeometry()
This virtual function discards any cached size hint information.
QRectF geometry() const
Returns the item's geometry (e.g., position and size) as a QRectF.
QGraphicsLayoutItem * parentLayoutItem() const
Returns the parent of this QGraphicsLayoutItem, or \nullptr if there is no parent,...
void setParentLayoutItem(QGraphicsLayoutItem *parent)
Sets the parent of this QGraphicsLayoutItem to parent.
virtual void setGeometry(const QRectF &rect)
This virtual function sets the geometry of the QGraphicsLayoutItem to rect, which is in parent coordi...
The QGraphicsLayout class provides the base class for all layouts in Graphics View.
virtual void invalidate()
Clears any cached geometry and size hint information in the layout, and posts a \l{QEvent::LayoutRequ...
static bool instantInvalidatePropagation()
The QGraphicsObject class provides a base class for all graphics items that require signals,...
bool enabled
whether the item is enabled or not
QPointF pos
the position of the item
QGraphicsObject * parent
the parent of the item
The 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 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)
The QGraphicsScene class provides a surface for managing a large number of 2D graphical items.
QStyle * style() const
QGraphicsLayout * layout
QStyle * styleForWidget(const QGraphicsWidget *widget) const
void setStyleForWidget(QGraphicsWidget *widget, QStyle *style)
The QGraphicsWidget class is the base class for all widget items in a QGraphicsScene.
void removeAction(QAction *action)
virtual void hideEvent(QHideEvent *event)
This event handler, for \l{QEvent::Hide}{Hide} events, is delivered after the widget has been hidden,...
virtual bool focusNextPrevChild(bool next)
Finds a new widget to give the keyboard focus to, as appropriate for Tab and Shift+Tab,...
void setStyle(QStyle *style)
Sets the widget's style to style.
void setLayout(QGraphicsLayout *layout)
Sets the layout for this widget to layout.
QStyle * style() const
Returns a pointer to the widget's style.
QRectF geometry
the geometry of the widget
void layoutChanged()
This signal gets emitted whenever the layout of the item changes.
QRectF windowFrameRect() const
Returns the widget's local rect including any window frame.
void setFocusPolicy(Qt::FocusPolicy policy)
void setContentsMargins(qreal left, qreal top, qreal right, qreal bottom)
This is an overloaded member function, provided for convenience. It differs from the above function o...
void setFont(const QFont &font)
QList< QAction * > actions() const
virtual void moveEvent(QGraphicsSceneMoveEvent *event)
This event handler, for \l{QEvent::GraphicsSceneMove}{GraphicsSceneMove} events, is delivered after t...
void setWindowFrameMargins(qreal left, qreal top, qreal right, qreal bottom)
This is an overloaded member function, provided for convenience. It differs from the above function o...
virtual bool windowFrameEvent(QEvent *e)
This event handler, for event, receives events for the window frame if this widget is a window.
QRectF rect() const
Returns the item's local rect as a QRectF.
void releaseShortcut(int id)
int type() const override
\reimp
Qt::WindowFlags windowFlags
the widget's window flags
void setAutoFillBackground(bool enabled)
void addActions(const QList< QAction * > &actions)
virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) override
\reimp
Qt::WindowType windowType() const
Returns the widgets window type.
Qt::LayoutDirection layoutDirection
the layout direction for this widget.
virtual void polishEvent()
This event is delivered to the item by the scene at some point after it has been constructed,...
bool sceneEvent(QEvent *event) override
QGraphicsWidget's implementation of sceneEvent() simply passes event to QGraphicsWidget::event().
virtual void paintWindowFrame(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget=nullptr)
This virtual function is called by QGraphicsScene to draw the window frame for windows using painter,...
bool isActiveWindow() const
Returns true if this widget's window is in the active window, or if the widget does not have a window...
bool autoFillBackground
whether the widget background is filled automatically
virtual void closeEvent(QCloseEvent *event)
This event handler, for event, can be reimplemented in a subclass to receive widget close events.
void setGeometry(const QRectF &rect) override
This virtual function sets the geometry of the QGraphicsLayoutItem to rect, which is in parent coordi...
QPainterPath shape() const override
\reimp
void resize(const QSizeF &size)
bool event(QEvent *event) override
\reimp
void getContentsMargins(qreal *left, qreal *top, qreal *right, qreal *bottom) const override
Gets the widget's contents margins.
QVariant itemChange(GraphicsItemChange change, const QVariant &value) override
\reimp
virtual Qt::WindowFrameSection windowFrameSectionAt(const QPointF &pos) const
bool close()
Call this function to close the widget.
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget=nullptr) override
\reimp
void setAttribute(Qt::WidgetAttribute attribute, bool on=true)
If on is true, this function enables attribute; otherwise attribute is disabled.
QPalette palette
the widget's palette
QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint=QSizeF()) const override
\reimp
virtual QVariant propertyChange(const QString &propertyName, const QVariant &value)
virtual void ungrabKeyboardEvent(QEvent *event)
This event handler, for event, can be reimplemented in a subclass to receive notifications for QEvent...
void setWindowFlags(Qt::WindowFlags wFlags)
virtual void changeEvent(QEvent *event)
This event handler can be reimplemented to handle state changes.
QRectF boundingRect() const override
\reimp
bool testAttribute(Qt::WidgetAttribute attribute) const
Returns true if attribute is enabled for this widget; otherwise, returns false.
void addAction(QAction *action)
void focusOutEvent(QFocusEvent *event) override
\reimp
QFont font
the widgets' font
virtual void showEvent(QShowEvent *event)
This event handler, for \l{QEvent::Show}{Show} events, is delivered before the widget has been shown,...
virtual void ungrabMouseEvent(QEvent *event)
This event handler, for event, can be reimplemented in a subclass to receive notifications for QEvent...
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)
This event handler, for event, can be reimplemented in a subclass to receive notifications for QEvent...
virtual void initStyleOption(QStyleOption *option) const
Populates a style option object for this widget based on its current state, and stores the output in ...
void unsetWindowFrameMargins()
Resets the window frame margins to the default value, provided by the style.
void setWindowTitle(const QString &title)
virtual void grabMouseEvent(QEvent *event)
This event handler, for event, can be reimplemented in a subclass to receive notifications for QEvent...
void setPalette(const QPalette &palette)
QRectF windowFrameGeometry() const
Returns the widget's geometry in parent coordinates including any window frame.
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
Gets the widget's window frame margins.
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
If this widget is currently managed by a layout, this function notifies the layout that the widget's ...
void focusInEvent(QFocusEvent *event) override
\reimp
virtual void resizeEvent(QGraphicsSceneResizeEvent *event)
This event handler, for \l{QEvent::GraphicsSceneResize}{GraphicsSceneResize} events,...
QString windowTitle
This property holds the window title (caption).
void adjustSize()
Adjusts the size of the widget to its effective preferred size hint.
static void setTabOrder(QGraphicsWidget *first, QGraphicsWidget *second)
Moves the second widget around the ring of focus widgets so that keyboard focus moves from the first ...
virtual void hoverMoveEvent(QGraphicsSceneHoverEvent *event) override
\reimp
void insertAction(QAction *before, QAction *action)
QGraphicsWidget * focusWidget() const
If this widget, a child or descendant of this widget currently has input focus, this function will re...
static QGuiApplicationPrivate * instance()
bool remove(const Key &key)
Removes the item that has the key from the hash.
Definition qhash.h:958
T value(const Key &key) const noexcept
Definition qhash.h:1054
The QHideEvent class provides an event which is sent after a widget is hidden.
Definition qevent.h:586
The QKeySequence class encapsulates a key sequence as used by shortcuts.
bool isEmpty() const
Returns true if the key sequence is empty; otherwise returns false.
qsizetype size() const noexcept
Definition qlist.h:397
const_reference at(qsizetype i) const noexcept
Definition qlist.h:446
qsizetype removeAll(const AT &t)
Definition qlist.h:592
void append(parameter_type t)
Definition qlist.h:458
\inmodule QtCore
Definition qmargins.h:270
constexpr bool isNull() const noexcept
Returns true if all margins are very close to 0; otherwise returns false.
Definition qmargins.h:374
\inmodule QtCore
Definition qmutex.h:313
\inmodule QtCore
Definition qmutex.h:281
QString objectName
the name of this object
Definition qobject.h:107
virtual bool event(QEvent *event)
This virtual function receives events to an object and should return true if the event e was recogniz...
Definition qobject.cpp:1389
void deleteLater()
\threadsafe
Definition qobject.cpp:2435
\inmodule QtGui
void addRect(const QRectF &rect)
Adds the given rectangle to this path as a closed subpath.
The QPainter class performs low-level painting on widgets and other paint devices.
Definition qpainter.h:46
void setClipRect(const QRectF &, Qt::ClipOperation op=Qt::ReplaceClip)
Enables clipping, and sets the clip region to the given rectangle using the given clip operation.
void restore()
Restores the current painter state (pops a saved state off the stack).
void save()
Saves the current painter state (pushes the state onto a stack).
void setFont(const QFont &f)
Sets the painter's font to the given font.
void fillPath(const QPainterPath &path, const QBrush &brush)
Fills the given path using the given brush.
void translate(const QPointF &offset)
Translates the coordinate system by the given offset; i.e.
void fillRect(const QRectF &, const QBrush &)
Fills the given rectangle with the brush specified.
void setClipRegion(const QRegion &, Qt::ClipOperation op=Qt::ReplaceClip)
Sets the clip region to the given region using the specified clip operation.
The QPalette class contains color groups for each widget state.
Definition qpalette.h:19
ResolveMask resolveMask() const
Definition qpalette.cpp:999
@ Inactive
Definition qpalette.h:49
@ Disabled
Definition qpalette.h:49
QPalette resolve(const QPalette &other) const
Returns a new QPalette that is a union of this instance and other.
Definition qpalette.cpp:963
Returns a copy of the pixmap that is transformed using the given transformation transform and transfo...
Definition qpixmap.h:27
\inmodule QtCore\reentrant
Definition qpoint.h:217
constexpr qreal x() const noexcept
Returns the x coordinate of this point.
Definition qpoint.h:343
constexpr qreal y() const noexcept
Returns the y coordinate of this point.
Definition qpoint.h:348
\inmodule QtCore\reentrant
Definition qpoint.h:25
\inmodule QtCore\reentrant
Definition qrect.h:484
constexpr QRectF adjusted(qreal x1, qreal y1, qreal x2, qreal y2) const noexcept
Returns a new rectangle with dx1, dy1, dx2 and dy2 added respectively to the existing coordinates of ...
Definition qrect.h:813
constexpr QPointF topLeft() const noexcept
Returns the position of the rectangle's top-left corner.
Definition qrect.h:511
constexpr QSizeF size() const noexcept
Returns the size of the rectangle.
Definition qrect.h:735
constexpr QRect toRect() const noexcept
Returns a QRect based on the values of this rectangle.
Definition qrect.h:859
\inmodule QtCore\reentrant
Definition qrect.h:30
constexpr void adjust(int x1, int y1, int x2, int y2) noexcept
Adds dx1, dy1, dx2 and dy2 respectively to the existing coordinates of the rectangle.
Definition qrect.h:373
bool contains(const QRect &r, bool proper=false) const noexcept
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qrect.cpp:855
constexpr void setHeight(int h) noexcept
Sets the height of the rectangle to the given height.
Definition qrect.h:384
T * data() const noexcept
Returns the value of the pointer referenced by this object.
The QShowEvent class provides an event that is sent when a widget is shown.
Definition qevent.h:578
\inmodule QtCore
Definition qsize.h:208
constexpr bool isValid() const noexcept
Returns true if both the width and height are equal to or greater than 0; otherwise returns false.
Definition qsize.h:329
constexpr qreal width() const noexcept
Returns the width.
Definition qsize.h:332
constexpr qreal height() const noexcept
Returns the height.
Definition qsize.h:335
\inmodule QtCore
Definition qsize.h:25
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
static QString fromLatin1(QByteArrayView ba)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qstring.cpp:5871
static QString number(int, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qstring.cpp:8084
The QStyleHintReturnMask class provides style hints that return a QRegion.
\variable QStyleOptionFocusRect::backgroundColor
The QStyleOptionGraphicsItem class is used to describe the parameters needed to draw a QGraphicsItem.
\variable QStyleOptionToolBox::selectedPosition
The QStyleOption class stores the parameters used by QStyle functions.
QStyle::State state
The QStyle class is an abstract base class that encapsulates the look and feel of a GUI.
Definition qstyle.h:29
@ State_Window
Definition qstyle.h:84
@ State_MouseOver
Definition qstyle.h:80
@ State_Sunken
Definition qstyle.h:69
@ State_HasFocus
Definition qstyle.h:75
@ State_Active
Definition qstyle.h:83
@ State_Enabled
Definition qstyle.h:67
@ State_None
Definition qstyle.h:66
virtual void drawComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, QPainter *p, const QWidget *widget=nullptr) const =0
Draws the given control using the provided painter with the style options specified by option.
@ SH_TitleBar_NoBorder
Definition qstyle.h:611
@ SH_WindowFrame_Mask
Definition qstyle.h:640
virtual int styleHint(StyleHint stylehint, const QStyleOption *opt=nullptr, const QWidget *widget=nullptr, QStyleHintReturn *returnData=nullptr) const =0
Returns an integer representing the specified style hint for the given widget described by the provid...
@ PM_MdiSubWindowFrameWidth
Definition qstyle.h:473
@ CC_TitleBar
Definition qstyle.h:337
@ PE_FrameWindow
Definition qstyle.h:112
virtual int pixelMetric(PixelMetric metric, const QStyleOption *option=nullptr, const QWidget *widget=nullptr) const =0
Returns the value of the given pixel metric.
virtual void drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPainter *p, const QWidget *w=nullptr) const =0
Draws the given primitive element with the provided painter using the style options specified by opti...
\inmodule QtCore
Definition qvariant.h:65
The QWidget class is the base class of all user interface objects.
Definition qwidget.h:99
QLayout * layout() const
Returns the layout manager that is installed on this widget, or \nullptr if no layout manager is inst...
QOpenGLWidget * widget
[1]
rect
[4]
direction
short next
Definition keywords.cpp:445
Combined button and popup list for selecting options.
WidgetAttribute
Definition qnamespace.h:282
@ WA_SetLayoutDirection
Definition qnamespace.h:323
@ WA_SetPalette
Definition qnamespace.h:303
@ WA_RightToLeft
Definition qnamespace.h:322
@ WA_Resized
Definition qnamespace.h:308
@ WA_SetStyle
Definition qnamespace.h:356
@ WA_NoSystemBackground
Definition qnamespace.h:291
@ WA_SetFont
Definition qnamespace.h:304
@ WA_OpaquePaintEvent
Definition qnamespace.h:287
@ WA_DeleteOnClose
Definition qnamespace.h:321
@ IntersectClip
LayoutDirection
@ LeftToRight
@ RightToLeft
FocusPolicy
Definition qnamespace.h:106
@ NoFocus
Definition qnamespace.h:107
WindowFrameSection
@ LeftSection
@ NoSection
@ BottomSection
@ TopRightSection
@ TopLeftSection
@ TitleBarArea
@ BottomLeftSection
@ BottomRightSection
@ TopSection
@ RightSection
WindowType
Definition qnamespace.h:205
@ FramelessWindowHint
Definition qnamespace.h:225
@ ToolTip
Definition qnamespace.h:213
@ Popup
Definition qnamespace.h:211
@ WindowType_Mask
Definition qnamespace.h:220
@ Window
Definition qnamespace.h:207
@ MaximumSize
@ PreferredSize
@ MinimumSize
@ BacktabFocusReason
@ TabFocusReason
ShortcutContext
static void * context
#define Q_FALLTHROUGH()
#define qApp
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
EGLOutputLayerEXT EGLint attribute
#define Q_GLOBAL_STATIC(TYPE, NAME,...)
#define qDebug
[1]
Definition qlogging.h:164
#define qWarning
Definition qlogging.h:166
GLint GLint GLint GLint GLint x
[0]
GLfloat GLfloat GLfloat w
[0]
GLint GLsizei GLsizei height
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLuint index
[2]
GLboolean r
[2]
GLdouble GLdouble GLdouble GLdouble top
GLdouble GLdouble right
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
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
GLdouble s
[6]
Definition qopenglext.h:235
GLsizei const GLchar *const * path
GLuint GLenum option
#define Q_ASSERT(cond)
Definition qrandom.cpp:47
QScopeGuard< typename std::decay< F >::type > qScopeGuard(F &&f)
[qScopeGuard]
Definition qscopeguard.h:60
bool qWidgetShortcutContextMatcher(QObject *object, Qt::ShortcutContext context)
#define qPrintable(string)
Definition qstring.h:1531
static void fillBackground(QPainter *p, const QRectF &rect, QBrush brush, const QPointF &origin, const QRectF &gradientRect=QRectF())
#define emit
#define Q_UNUSED(x)
unsigned int uint
Definition qtypes.h:34
double qreal
Definition qtypes.h:187
#define QWIDGETSIZE_MAX
Definition qwidget.h:917
const char className[16]
[1]
Definition qwizard.cpp:100
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]