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
qgraphicsproxywidget.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 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 "qgraphicslayout.h"
8#include "private/qgraphicsproxywidget_p.h"
9#include "private/qwidget_p.h"
10#include "private/qapplication_p.h"
11
12#include <QtCore/qdebug.h>
13#include <QtGui/qevent.h>
14#include <QtWidgets/qgraphicsscene.h>
15#include <QtWidgets/qgraphicssceneevent.h>
16#include <QtWidgets/qlayout.h>
17#include <QtGui/qpainter.h>
18#include <QtWidgets/qstyleoption.h>
19#include <QtWidgets/qgraphicsview.h>
20#if QT_CONFIG(lineedit)
21#include <QtWidgets/qlineedit.h>
22#endif
23#if QT_CONFIG(textedit)
24#include <QtWidgets/qtextedit.h>
25#endif
26
28
29//#define GRAPHICSPROXYWIDGET_DEBUG
30
158Q_WIDGETS_EXPORT extern bool qt_tab_all_widgets();
159
165 dragDropWidget(nullptr),
166 posChangeMode(NoMode),
167 sizeChangeMode(NoMode),
168 visibleChangeMode(NoMode),
169 enabledChangeMode(NoMode),
170 styleChangeMode(NoMode),
171 paletteChangeMode(NoMode),
172 tooltipChangeMode(NoMode),
173 focusFromWidgetToProxy(false),
174 proxyIsGivingFocus(false)
175{
176}
177
184
189{
191 q->setFocusPolicy(Qt::WheelFocus);
192 q->setAcceptDrops(true);
193}
194
199{
201 mouseEvent.setPos(event->pos());
202 mouseEvent.setScreenPos(event->screenPos());
203 mouseEvent.setButton(Qt::NoButton);
204 mouseEvent.setButtons({ });
205 mouseEvent.setModifiers(event->modifiers());
206 mouseEvent.setTimestamp(event->timestamp());
207 sendWidgetMouseEvent(&mouseEvent);
208 event->setAccepted(mouseEvent.isAccepted());
209}
210
215{
216 if (!event || !widget || !widget->isVisible())
217 return;
219
220 // Find widget position and receiver.
221 QPointF pos = event->pos();
222 QPointer<QWidget> alienWidget = widget->childAt(pos.toPoint());
223 QPointer<QWidget> receiver = alienWidget ? alienWidget : widget;
224
225 if (QWidgetPrivate::nearestGraphicsProxyWidget(receiver) != q)
226 return; //another proxywidget will handle the events
227
228 // Translate QGraphicsSceneMouse events to QMouseEvents.
230 switch (event->type()) {
234 embeddedMouseGrabber = receiver;
235 else
236 receiver = embeddedMouseGrabber;
237 break;
241 receiver = embeddedMouseGrabber;
242 break;
246 embeddedMouseGrabber = receiver;
247 else
248 receiver = embeddedMouseGrabber;
249 break;
253 receiver = embeddedMouseGrabber;
254 break;
255 default:
256 Q_ASSERT_X(false, "QGraphicsProxyWidget", "internal error");
257 break;
258 }
259
262 lastWidgetUnderMouse = receiver;
263 }
264
265 // Map event position from us to the receiver
266 pos = mapToReceiver(pos, receiver);
267
268 // Send mouse event.
269 QMouseEvent mouseEvent(type, pos, receiver->mapTo(receiver->topLevelWidget(), pos.toPoint()),
270 receiver->mapToGlobal(pos.toPoint()),
271 event->button(), event->buttons(), event->modifiers(), event->source());
272 mouseEvent.setTimestamp(event->timestamp());
273
274 QWidget *embeddedMouseGrabberPtr = (QWidget *)embeddedMouseGrabber;
275 QApplicationPrivate::sendMouseEvent(receiver, &mouseEvent, alienWidget, widget,
276 &embeddedMouseGrabberPtr, lastWidgetUnderMouse, event->spontaneous());
277 embeddedMouseGrabber = embeddedMouseGrabberPtr;
278
279 // Handle enter/leave events when last button is released from mouse
280 // grabber child widget.
283 if (q->rect().contains(event->pos()) && q->acceptHoverEvents())
284 lastWidgetUnderMouse = alienWidget ? alienWidget : widget;
285 else // released on the frame our outside the item, or doesn't accept hover events.
286 lastWidgetUnderMouse = nullptr;
287
289 embeddedMouseGrabber = nullptr;
290
291#ifndef QT_NO_CURSOR
292 // ### Restore the cursor, don't override it.
294 q->unsetCursor();
295#endif
296 }
297
298 event->setAccepted(mouseEvent.isAccepted());
299}
300
302{
304 if (!event || !widget || !widget->isVisible())
305 return;
306
307 QPointer<QWidget> receiver = widget->focusWidget();
308 if (!receiver)
309 receiver = widget;
310 Q_ASSERT(receiver);
311
312 do {
313 bool res = QCoreApplication::sendEvent(receiver, event);
314 if ((res && event->isAccepted()) || (q->isWindow() && receiver == widget))
315 break;
316 receiver = receiver->parentWidget();
317 } while (receiver);
318}
319
324{
326 QPointer<QWidget> widgetGuard = widget;
328 if (widgetGuard && event.isAccepted())
330}
331
337{
338 if (!widget)
339 return nullptr;
340
341 // Run around the focus chain until we find a widget that can take tab focus.
342 if (!child) {
344 } else {
345 child = next ? child->nextInFocusChain() : child->previousInFocusChain();
346 if ((next && child == widget) || (!next && child == widget->previousInFocusChain())) {
347 return nullptr;
348 }
349 }
350
351 if (!child)
352 return nullptr;
353
354 QWidget *oldChild = child;
356 do {
357 if (child->isEnabled()
358 && child->isVisibleTo(widget)
359 && ((child->focusPolicy() & focus_flag) == focus_flag)
360 && !(child->d_func()->extra && child->d_func()->extra->focus_proxy)) {
361 return child;
362 }
363 child = next ? child->nextInFocusChain() : child->previousInFocusChain();
364 } while (child != oldChild && !(next && child == widget) && !(!next && child == widget->previousInFocusChain()));
365 return nullptr;
366}
367
372{
374 if (!widget.isNull()) {
375 if (const auto &extra = widget->d_func()->extra)
376 extra->proxyWidget = nullptr;
377 }
378 widget = nullptr;
379 delete q;
380}
381
388
393{
395 if (!widget)
396 return;
397
398 QRectF widgetGeometry = widget->geometry();
399 QWidget *parentWidget = widget->parentWidget();
400 if (widget->isWindow()) {
401 QGraphicsProxyWidget *proxyParent = nullptr;
402 if (parentWidget && (proxyParent = qobject_cast<QGraphicsProxyWidget *>(q->parentWidget()))) {
403 // Nested window proxy (e.g., combobox popup), map widget to the
404 // parent widget's global coordinates, and map that to the parent
405 // proxy's child coordinates.
406 widgetGeometry.moveTo(proxyParent->subWidgetRect(parentWidget).topLeft()
407 + parentWidget->mapFromGlobal(widget->pos()));
408 }
409 }
410
411 // Adjust to size hint if the widget has never been resized.
412 if (!widget->size().isValid())
413 widgetGeometry.setSize(widget->sizeHint());
414
415 // Assign new geometry.
418 q->setGeometry(widgetGeometry);
421}
422
427{
429 if (!widget)
430 return;
431
432 QWidget *focusWidget = widget->focusWidget();
433 if (!focusWidget)
434 focusWidget = widget;
437}
438
447{
448 const auto &extra = subWin->d_func()->extra;
449 if (!extra || !extra->proxyWidget) {
450 QGraphicsProxyWidget *subProxy = new QGraphicsProxyWidget(q_func(), subWin->windowFlags());
451 subProxy->d_func()->setWidget_helper(subWin, false);
452 }
453}
454
463{
464 for (QGraphicsItem *child : std::as_const(children)) {
465 if (child->isWidget()) {
466 if (QGraphicsProxyWidget *proxy = qobject_cast<QGraphicsProxyWidget *>(static_cast<QGraphicsWidget *>(child))) {
467 if (proxy->widget() == subWin) {
468 proxy->setWidget(nullptr);
470 delete proxy;
471 return;
472 }
473 }
474 }
475 }
476}
477
479{
480 return true;
481}
482
487{
488 QPointF p = pos;
489 // Map event position from us to the receiver, preserving its
490 // precision (don't use QWidget::mapFrom here).
491 while (receiver && receiver != widget) {
492 p -= QPointF(receiver->pos());
493 receiver = receiver->parentWidget();
494 }
495 return p;
496}
497
503 : QGraphicsWidget(*new QGraphicsProxyWidgetPrivate, parent, wFlags)
504{
506 d->init();
507}
508
513{
515 if (d->widget) {
516 d->widget->removeEventFilter(this);
517 QObject::disconnect(d->widget, SIGNAL(destroyed()), this, SLOT(_q_removeWidgetSlot()));
518 delete d->widget;
519 }
520}
521
555{
557 d->setWidget_helper(widget, true);
558}
559
561{
563 if (newWidget == widget)
564 return;
565 if (widget) {
569 widget->d_func()->extra->proxyWidget = nullptr;
572 widget->update();
573
574 const auto childItems = q->childItems();
575 for (QGraphicsItem *child : childItems) {
576 if (child->d_ptr->isProxyWidget()) {
577 QGraphicsProxyWidget *childProxy = static_cast<QGraphicsProxyWidget *>(child);
578 QWidget *parent = childProxy->widget();
579 while (parent && parent->parentWidget()) {
580 if (parent == widget)
581 break;
583 }
584 if (!childProxy->widget() || parent != widget)
585 continue;
586 childProxy->setWidget(nullptr);
587 delete childProxy;
588 }
589 }
590
591 widget = nullptr;
592#ifndef QT_NO_CURSOR
593 q->unsetCursor();
594#endif
595 q->setAcceptHoverEvents(false);
596 if (!newWidget)
597 q->update();
598 }
599 if (!newWidget)
600 return;
601 if (!newWidget->isWindow()) {
602 const auto &extra = newWidget->parentWidget()->d_func()->extra;
603 if (!extra || !extra->proxyWidget) {
604 qWarning("QGraphicsProxyWidget::setWidget: cannot embed widget %p "
605 "which is not a toplevel widget, and is not a child of an embedded widget", newWidget);
606 return;
607 }
608 }
609
610 // Register this proxy within the widget's private.
611 // ### This is a bit backdoorish
612 QWExtra *extra = newWidget->d_func()->extra.get();
613 if (!extra) {
614 newWidget->d_func()->createExtra();
615 extra = newWidget->d_func()->extra.get();
616 }
617 QGraphicsProxyWidget **proxyWidget = &extra->proxyWidget;
618 if (*proxyWidget) {
619 if (*proxyWidget != q) {
620 qWarning("QGraphicsProxyWidget::setWidget: cannot embed widget %p"
621 "; already embedded", newWidget);
622 }
623 return;
624 }
625 *proxyWidget = q;
626
627 newWidget->setAttribute(Qt::WA_DontShowOnScreen);
628 newWidget->ensurePolished();
629 // Do not wait for this widget to close before the app closes ###
630 // shouldn't this widget inherit the attribute?
631 newWidget->setAttribute(Qt::WA_QuitOnClose, false);
632 q->setAcceptHoverEvents(true);
633
634 if (newWidget->testAttribute(Qt::WA_NoSystemBackground))
635 q->setAttribute(Qt::WA_NoSystemBackground);
636 if (newWidget->testAttribute(Qt::WA_OpaquePaintEvent))
637 q->setAttribute(Qt::WA_OpaquePaintEvent);
638
639 widget = newWidget;
640
641 // Changes only go from the widget to the proxy.
646
647 if ((autoShow && !newWidget->testAttribute(Qt::WA_WState_ExplicitShowHide)) || !newWidget->testAttribute(Qt::WA_WState_Hidden)) {
648 newWidget->show();
649 }
650
651 // Copy the state from the widget onto the proxy.
652#ifndef QT_NO_CURSOR
653 if (newWidget->testAttribute(Qt::WA_SetCursor))
654 q->setCursor(widget->cursor());
655#endif
656 q->setEnabled(newWidget->isEnabled());
657 q->setVisible(newWidget->isVisible());
658 q->setLayoutDirection(newWidget->layoutDirection());
659 if (newWidget->testAttribute(Qt::WA_SetStyle))
660 q->setStyle(widget->style());
661
664
665 if (!newWidget->testAttribute(Qt::WA_Resized))
666 newWidget->adjustSize();
667
668 q->setContentsMargins(newWidget->contentsMargins());
669 q->setWindowTitle(newWidget->windowTitle());
670
671 // size policies and constraints..
672 q->setSizePolicy(newWidget->sizePolicy());
673 QSize sz = newWidget->minimumSize();
674 q->setMinimumSize(sz.isNull() ? QSizeF() : QSizeF(sz));
675 sz = newWidget->maximumSize();
676 q->setMaximumSize(sz.isNull() ? QSizeF() : QSizeF(sz));
677
679
681
682 // Hook up the event filter to keep the state up to date.
683 newWidget->installEventFilter(q);
684 QObject::connect(newWidget, SIGNAL(destroyed()), q, SLOT(_q_removeWidgetSlot()));
685
686 // Changes no longer go only from the widget to the proxy.
691}
692
699{
700 Q_D(const QGraphicsProxyWidget);
701 return d->widget;
702}
703
714{
715 Q_D(const QGraphicsProxyWidget);
716 if (!widget || !d->widget)
717 return QRectF();
718 if (d->widget == widget || d->widget->isAncestorOf(widget))
719 return QRectF(widget->mapTo(d->widget, QPoint(0, 0)), widget->size());
720 return QRectF();
721}
722
727{
729 bool proxyResizesWidget = !d->posChangeMode && !d->sizeChangeMode;
730 if (proxyResizesWidget) {
733 }
735 if (proxyResizesWidget) {
736 d->posChangeMode = QGraphicsProxyWidgetPrivate::NoMode;
737 d->sizeChangeMode = QGraphicsProxyWidgetPrivate::NoMode;
738 }
739}
740
745 const QVariant &value)
746{
748
749 switch (change) {
751 // The item's position is either changed directly on the proxy, in
752 // which case the position change should propagate to the widget,
753 // otherwise it happens as a side effect when filtering QEvent::Move.
754 if (!d->posChangeMode)
756 break;
758 // Move the internal widget if we're in widget-to-proxy
759 // mode. Otherwise the widget has already moved.
760 if (d->widget && d->posChangeMode != QGraphicsProxyWidgetPrivate::WidgetToProxyMode)
761 d->widget->move(value.toPoint());
763 d->posChangeMode = QGraphicsProxyWidgetPrivate::NoMode;
764 break;
766 if (!d->visibleChangeMode)
768 break;
770 if (d->widget && d->visibleChangeMode != QGraphicsProxyWidgetPrivate::WidgetToProxyMode)
771 d->widget->setVisible(isVisible());
772 if (d->visibleChangeMode == QGraphicsProxyWidgetPrivate::ProxyToWidgetMode)
773 d->visibleChangeMode = QGraphicsProxyWidgetPrivate::NoMode;
774 break;
776 if (!d->enabledChangeMode)
778 break;
780 if (d->widget && d->enabledChangeMode != QGraphicsProxyWidgetPrivate::WidgetToProxyMode)
781 d->widget->setEnabled(isEnabled());
782 if (d->enabledChangeMode == QGraphicsProxyWidgetPrivate::ProxyToWidgetMode)
783 d->enabledChangeMode = QGraphicsProxyWidgetPrivate::NoMode;
784 break;
785 default:
786 break;
787 }
788 return QGraphicsWidget::itemChange(change, value);
789}
790
795{
797 if (!d->widget)
799
800 switch (event->type()) {
804 break;
806 // Propagate style changes to the embedded widget.
807 if (!d->styleChangeMode) {
809 d->widget->setStyle(style());
810 d->styleChangeMode = QGraphicsProxyWidgetPrivate::NoMode;
811 }
812 break;
813 case QEvent::FontChange: {
814 // Propagate to widget.
815 QWidgetPrivate *wd = d->widget->d_func();
816 int mask = d->font.resolveMask() | d->inheritedFontResolveMask;
818 wd->resolveFont();
819 break;
820 }
822 // Propagate to widget.
823 QWidgetPrivate *wd = d->widget->d_func();
824 int mask = d->palette.resolveMask() | d->inheritedPaletteResolveMask;
826 wd->resolvePalette();
827 break;
828 }
829 case QEvent::InputMethod: {
831 if (event->isAccepted())
832 return true;
833 return false;
834 }
836 QWidget *focusWidget = d->widget->focusWidget();
837 while (focusWidget) {
839 if (event->isAccepted())
840 return true;
842 }
843 return false;
844 }
845 case QEvent::KeyPress: {
846 QKeyEvent *k = static_cast<QKeyEvent *>(event);
847 if (k->key() == Qt::Key_Tab || k->key() == Qt::Key_Backtab) {
848 if (!(k->modifiers() & (Qt::ControlModifier | Qt::AltModifier))) { //### Add MetaModifier?
849 QWidget *focusWidget = d->widget->focusWidget();
850 while (focusWidget) {
852 if ((res && event->isAccepted()) || (isWindow() && focusWidget == d->widget)) {
853 event->accept();
854 break;
855 }
857 }
858 return true;
859 }
860 }
861 break;
862 }
863#if QT_CONFIG(tooltip)
865 // Propagate the help event (for tooltip) to the widget under mouse
866 if (d->lastWidgetUnderMouse) {
868 QPoint pos = d->mapToReceiver(mapFromScene(he->scenePos()), d->lastWidgetUnderMouse).toPoint();
869 QHelpEvent e(QEvent::ToolTip, pos, he->screenPos());
870 QCoreApplication::sendEvent(d->lastWidgetUnderMouse, &e);
871 event->setAccepted(e.isAccepted());
872 return e.isAccepted();
873 }
874 break;
875 }
877 // Propagate tooltip change to the widget
878 if (!d->tooltipChangeMode) {
880 d->widget->setToolTip(toolTip());
881 d->tooltipChangeMode = QGraphicsProxyWidgetPrivate::NoMode;
882 }
883 break;
884 }
885#endif
888 case QEvent::TouchEnd: {
889 QTouchEvent *touchEvent = static_cast<QTouchEvent *>(event);
890 bool res = QApplicationPrivate::translateRawTouchEvent(d->widget, touchEvent);
891 if (res & touchEvent->isAccepted())
892 return true;
893
894 break;
895 }
896 default:
897 break;
898 }
900}
901
906{
908
909 if (object == d->widget) {
910 switch (event->type()) {
913 break;
914 case QEvent::Resize:
915 // If the widget resizes itself, we resize the proxy too.
916 // Prevent feed-back by checking the geometry change mode.
917 if (!d->sizeChangeMode)
918 d->updateProxyGeometryFromWidget();
919 break;
920 case QEvent::Move:
921 // If the widget moves itself, we move the proxy too. Prevent
922 // feed-back by checking the geometry change mode.
923 if (!d->posChangeMode)
924 d->updateProxyGeometryFromWidget();
925 break;
926 case QEvent::Hide:
927 case QEvent::Show:
928 // If the widget toggles its visible state, the proxy will follow.
929 if (!d->visibleChangeMode) {
931 setVisible(event->type() == QEvent::Show);
932 d->visibleChangeMode = QGraphicsProxyWidgetPrivate::NoMode;
933 }
934 break;
936 // If the widget toggles its enabled state, the proxy will follow.
937 if (!d->enabledChangeMode) {
939 setEnabled(d->widget->isEnabled());
940 d->enabledChangeMode = QGraphicsProxyWidgetPrivate::NoMode;
941 }
942 break;
944 // Propagate style changes to the proxy.
945 if (!d->styleChangeMode) {
947 setStyle(d->widget->style());
948 d->styleChangeMode = QGraphicsProxyWidgetPrivate::NoMode;
949 }
950 break;
951#if QT_CONFIG(tooltip)
953 // Propagate tooltip change to the proxy.
954 if (!d->tooltipChangeMode) {
956 setToolTip(d->widget->toolTip());
957 d->tooltipChangeMode = QGraphicsProxyWidgetPrivate::NoMode;
958 }
959 break;
960#endif
961 default:
962 break;
963 }
964 }
965 return QGraphicsWidget::eventFilter(object, event);
966}
967
975
983
984#ifndef QT_NO_CONTEXTMENU
989{
991 if (!event || !d->widget || !d->widget->isVisible() || !hasFocus())
992 return;
993
994 // Find widget position and receiver.
995 QPointF pos = event->pos();
996 QPointer<QWidget> alienWidget = d->widget->childAt(pos.toPoint());
997 QPointer<QWidget> receiver = alienWidget ? alienWidget : d->widget;
998
999 // Map event position from us to the receiver
1000 pos = d->mapToReceiver(pos, receiver);
1001
1002 QPoint globalPos = receiver->mapToGlobal(pos.toPoint());
1003 //If the receiver by-pass the proxy its popups
1004 //will be top level QWidgets therefore they need
1005 //the screen position. mapToGlobal expect the widget to
1006 //have proper coordinates in regards of the windowing system
1007 //but it's not true because the widget is embedded.
1008 if (bypassGraphicsProxyWidget(receiver))
1009 globalPos = event->screenPos();
1010
1011 // Send mouse event. ### Doesn't propagate the event.
1013 pos.toPoint(), globalPos, event->modifiers());
1014 contextMenuEvent.setTimestamp(event->timestamp());
1016
1017 event->setAccepted(contextMenuEvent.isAccepted());
1018}
1019#endif // QT_NO_CONTEXTMENU
1020
1021#if QT_CONFIG(draganddrop)
1026{
1027#if !QT_CONFIG(draganddrop)
1028 Q_UNUSED(event);
1029#else
1031 if (!d->widget)
1032 return;
1033
1034 QDragEnterEvent proxyDragEnter(event->pos().toPoint(), event->dropAction(), event->mimeData(), event->buttons(), event->modifiers());
1035 proxyDragEnter.setAccepted(event->isAccepted());
1036 QCoreApplication::sendEvent(d->widget, &proxyDragEnter);
1037 event->setAccepted(proxyDragEnter.isAccepted());
1038 if (proxyDragEnter.isAccepted()) // we discard answerRect
1039 event->setDropAction(proxyDragEnter.dropAction());
1040#endif
1041}
1046{
1047 Q_UNUSED(event);
1048#if QT_CONFIG(draganddrop)
1050 if (!d->widget || !d->dragDropWidget)
1051 return;
1052 QDragLeaveEvent proxyDragLeave;
1053 QCoreApplication::sendEvent(d->dragDropWidget, &proxyDragLeave);
1054 d->dragDropWidget = nullptr;
1055#endif
1056}
1057
1062{
1063#if !QT_CONFIG(draganddrop)
1064 Q_UNUSED(event);
1065#else
1067 if (!d->widget)
1068 return;
1069 QPointF p = event->pos();
1070 event->ignore();
1071 QPointer<QWidget> subWidget = d->widget->childAt(p.toPoint());
1072 QPointer<QWidget> receiver = subWidget ? subWidget : d->widget;
1073 bool eventDelivered = false;
1074 for (; receiver; receiver = receiver->parentWidget()) {
1075 if (!receiver->isEnabled() || !receiver->acceptDrops())
1076 continue;
1077 // Map event position from us to the receiver
1078 QPoint receiverPos = d->mapToReceiver(p, receiver).toPoint();
1079 if (receiver != d->dragDropWidget) {
1080 // Try to enter before we leave
1081 QDragEnterEvent dragEnter(receiverPos, event->possibleActions(), event->mimeData(), event->buttons(), event->modifiers());
1082 dragEnter.setDropAction(event->proposedAction());
1083 QCoreApplication::sendEvent(receiver, &dragEnter);
1084 event->setAccepted(dragEnter.isAccepted());
1085 event->setDropAction(dragEnter.dropAction());
1086 if (!event->isAccepted()) {
1087 // propagate to the parent widget
1088 continue;
1089 }
1090
1091 d->lastDropAction = event->dropAction();
1092
1093 if (d->dragDropWidget) {
1094 QDragLeaveEvent dragLeave;
1095 QCoreApplication::sendEvent(d->dragDropWidget, &dragLeave);
1096 }
1097 d->dragDropWidget = receiver;
1098 }
1099
1100 QDragMoveEvent dragMove(receiverPos, event->possibleActions(), event->mimeData(), event->buttons(), event->modifiers());
1101 event->setDropAction(d->lastDropAction);
1102 QCoreApplication::sendEvent(receiver, &dragMove);
1103 event->setAccepted(dragMove.isAccepted());
1104 event->setDropAction(dragMove.dropAction());
1105 if (event->isAccepted())
1106 d->lastDropAction = event->dropAction();
1107 eventDelivered = true;
1108 break;
1109 }
1110
1111 if (!eventDelivered) {
1112 if (d->dragDropWidget) {
1113 // Leave the last drag drop item
1114 QDragLeaveEvent dragLeave;
1115 QCoreApplication::sendEvent(d->dragDropWidget, &dragLeave);
1116 d->dragDropWidget = nullptr;
1117 }
1118 // Propagate
1119 event->setDropAction(Qt::IgnoreAction);
1120 }
1121#endif
1122}
1123
1128{
1129#if !QT_CONFIG(draganddrop)
1130 Q_UNUSED(event);
1131#else
1133 if (d->widget && d->dragDropWidget) {
1134 QPoint widgetPos = d->mapToReceiver(event->pos(), d->dragDropWidget).toPoint();
1135 QDropEvent dropEvent(widgetPos, event->possibleActions(), event->mimeData(), event->buttons(), event->modifiers());
1136 QCoreApplication::sendEvent(d->dragDropWidget, &dropEvent);
1137 event->setAccepted(dropEvent.isAccepted());
1138 d->dragDropWidget = nullptr;
1139 }
1140#endif
1141}
1142#endif
1143
1151
1156{
1157 Q_UNUSED(event);
1159 // If hoverMove was compressed away, make sure we update properly here.
1160 if (d->lastWidgetUnderMouse) {
1161 QApplicationPrivate::dispatchEnterLeave(nullptr, d->lastWidgetUnderMouse, event->screenPos());
1162 d->lastWidgetUnderMouse = nullptr;
1163 }
1164}
1165
1170{
1172#ifdef GRAPHICSPROXYWIDGET_DEBUG
1173 qDebug("QGraphicsProxyWidget::hoverMoveEvent");
1174#endif
1175 // Ignore events on the window frame.
1176 if (!d->widget || !rect().contains(event->pos())) {
1177 if (d->lastWidgetUnderMouse) {
1178 QApplicationPrivate::dispatchEnterLeave(nullptr, d->lastWidgetUnderMouse, event->screenPos());
1179 d->lastWidgetUnderMouse = nullptr;
1180 }
1181 return;
1182 }
1183
1184 d->embeddedMouseGrabber = nullptr;
1185 d->sendWidgetMouseEvent(event);
1186}
1187
1195
1200{
1202 Q_UNUSED(event);
1203 d->embeddedMouseGrabber = nullptr;
1204}
1205
1210{
1212#ifdef GRAPHICSPROXYWIDGET_DEBUG
1213 qDebug("QGraphicsProxyWidget::mouseMoveEvent");
1214#endif
1215 d->sendWidgetMouseEvent(event);
1216}
1217
1222{
1224#ifdef GRAPHICSPROXYWIDGET_DEBUG
1225 qDebug("QGraphicsProxyWidget::mousePressEvent");
1226#endif
1227 d->sendWidgetMouseEvent(event);
1228}
1229
1234{
1236#ifdef GRAPHICSPROXYWIDGET_DEBUG
1237 qDebug("QGraphicsProxyWidget::mouseDoubleClickEvent");
1238#endif
1239 d->sendWidgetMouseEvent(event);
1240}
1241
1245#if QT_CONFIG(wheelevent)
1247{
1249#ifdef GRAPHICSPROXYWIDGET_DEBUG
1250 qDebug("QGraphicsProxyWidget::wheelEvent");
1251#endif
1252 if (!d->widget)
1253 return;
1254
1255 QPointF pos = event->pos();
1256 QPointer<QWidget> receiver = d->widget->childAt(pos.toPoint());
1257 if (!receiver)
1258 receiver = d->widget;
1259
1260 // high precision event streams go to the grabber, which will be the
1261 // QGraphicsView's viewport. We need to change that temporarily, otherwise
1262 // the event we send to the receiver get grabbed by the viewport, resulting
1263 // in infinite recursion
1264 QPointer<QWidget> prev_grabber = QApplicationPrivate::wheel_widget;
1265 if (event->phase() == Qt::ScrollBegin) {
1266 QApplicationPrivate::wheel_widget = receiver;
1267 } else if (event->phase() != Qt::NoScrollPhase && QApplicationPrivate::wheel_widget != receiver) {
1268 // this event is part of a stream that didn't start here, so ignore
1269 event->ignore();
1270 return;
1271 }
1272
1273 // Map event position from us to the receiver
1274 pos = d->mapToReceiver(pos, receiver);
1275
1276 // Send mouse event.
1277 QPoint angleDelta;
1278 if (event->orientation() == Qt::Horizontal)
1279 angleDelta.setX(event->delta());
1280 else
1281 angleDelta.setY(event->delta());
1282 // pixelDelta, inverted, scrollPhase and source from the original QWheelEvent
1283 // were not preserved in the QGraphicsSceneWheelEvent unfortunately
1284 QWheelEvent wheelEvent(pos, event->screenPos(), event->pixelDelta(), angleDelta,
1285 event->buttons(), event->modifiers(), event->phase(),
1286 event->isInverted(), Qt::MouseEventSynthesizedByQt,
1288 QPointer<QWidget> focusWidget = d->widget->focusWidget();
1289 extern bool qt_sendSpontaneousEvent(QObject *, QEvent *);
1291 event->setAccepted(wheelEvent.isAccepted());
1292
1293 if (event->phase() == Qt::ScrollBegin) {
1294 // reset the wheel grabber if the event wasn't accepted
1295 if (!wheelEvent.isAccepted())
1296 QApplicationPrivate::wheel_widget = prev_grabber;
1297 }
1298
1299 // ### Remove, this should be done by proper focusIn/focusOut events.
1300 if (focusWidget && !focusWidget->hasFocus()) {
1302 focusWidget = d->widget->focusWidget();
1305 }
1306}
1307#endif
1308
1313{
1315#ifdef GRAPHICSPROXYWIDGET_DEBUG
1316 qDebug("QGraphicsProxyWidget::mouseReleaseEvent");
1317#endif
1318 d->sendWidgetMouseEvent(event);
1319}
1320
1325{
1327#ifdef GRAPHICSPROXYWIDGET_DEBUG
1328 qDebug("QGraphicsProxyWidget::keyPressEvent");
1329#endif
1330 d->sendWidgetKeyEvent(event);
1331}
1332
1337{
1339#ifdef GRAPHICSPROXYWIDGET_DEBUG
1340 qDebug("QGraphicsProxyWidget::keyReleaseEvent");
1341#endif
1342 d->sendWidgetKeyEvent(event);
1343}
1344
1349{
1350#ifdef GRAPHICSPROXYWIDGET_DEBUG
1351 qDebug("QGraphicsProxyWidget::focusInEvent");
1352#endif
1354
1355 if (d->focusFromWidgetToProxy) {
1356 // Prevent recursion when the proxy autogains focus through the
1357 // embedded widget calling setFocus(). ### Could be done with event
1358 // filter on FocusIn instead?
1359 return;
1360 }
1361
1362 d->proxyIsGivingFocus = true;
1363
1364 switch (event->reason()) {
1365 case Qt::TabFocusReason: {
1366 if (QWidget *focusChild = d->findFocusChild(nullptr, true))
1367 focusChild->setFocus(event->reason());
1368 break;
1369 }
1371 if (QWidget *focusChild = d->findFocusChild(nullptr, false))
1372 focusChild->setFocus(event->reason());
1373 break;
1374 default:
1375 if (d->widget && d->widget->focusWidget()) {
1376 d->widget->focusWidget()->setFocus(event->reason());
1377 }
1378 break;
1379 }
1380
1381 // QTBUG-88016
1382 if (d->widget && d->widget->focusWidget()
1383 && d->widget->focusWidget()->testAttribute(Qt::WA_InputMethodEnabled))
1384 QApplication::inputMethod()->reset();
1385
1386 d->proxyIsGivingFocus = false;
1387}
1388
1393{
1394#ifdef GRAPHICSPROXYWIDGET_DEBUG
1395 qDebug("QGraphicsProxyWidget::focusOutEvent");
1396#endif
1398 if (d->widget) {
1399 // We need to explicitly remove subfocus from the embedded widget's
1400 // focus widget.
1401 if (QWidget *focusWidget = d->widget->focusWidget()) {
1402 // QTBUG-88016 proxyWidget set QTextEdit(QLineEdit etc.) when input preview text,
1403 // inputMethod should be reset when proxyWidget lost focus
1405 QApplication::inputMethod()->reset();
1406
1407 d->removeSubFocusHelper(focusWidget, event->reason());
1408 }
1409 }
1410}
1411
1416{
1418 if (!d->widget || !d->scene)
1420
1422 QWidget *lastFocusChild = d->widget->focusWidget();
1423 if (QWidget *newFocusChild = d->findFocusChild(lastFocusChild, next)) {
1424 newFocusChild->setFocus(reason);
1425 return true;
1426 }
1427
1429}
1430
1435{
1436 Q_D(const QGraphicsProxyWidget);
1437
1438 if (!d->widget || !hasFocus())
1439 return QVariant();
1440
1442 if (!focusWidget)
1443 focusWidget = d->widget;
1445 QPointF focusWidgetPos = subWidgetRect(focusWidget).topLeft();
1446 switch (v.userType()) {
1447 case QMetaType::QRectF:
1448 v = v.toRectF().translated(focusWidgetPos);
1449 break;
1450 case QMetaType::QPointF:
1451 v = v.toPointF() + focusWidgetPos;
1452 break;
1453 case QMetaType::QRect:
1454 v = v.toRect().translated(focusWidgetPos.toPoint());
1455 break;
1456 case QMetaType::QPoint:
1457 v = v.toPoint() + focusWidgetPos.toPoint();
1458 break;
1459 default:
1460 break;
1461 }
1462 return v;
1463}
1464
1469{
1470 // Forward input method events if the focus widget enables input methods.
1471 Q_D(const QGraphicsProxyWidget);
1472 QWidget *focusWidget = d->widget->focusWidget();
1475}
1476
1481{
1482 Q_D(const QGraphicsProxyWidget);
1483 if (!d->widget)
1484 return QGraphicsWidget::sizeHint(which, constraint);
1485
1486 QSizeF sh;
1487 switch (which) {
1488 case Qt::PreferredSize:
1489 if (QLayout *l = d->widget->layout())
1490 sh = l->sizeHint();
1491 else
1492 sh = d->widget->sizeHint();
1493 break;
1494 case Qt::MinimumSize:
1495 if (QLayout *l = d->widget->layout())
1496 sh = l->minimumSize();
1497 else
1498 sh = d->widget->minimumSizeHint();
1499 break;
1500 case Qt::MaximumSize:
1501 if (QLayout *l = d->widget->layout())
1502 sh = l->maximumSize();
1503 else
1505 break;
1506 case Qt::MinimumDescent:
1507 sh = constraint;
1508 break;
1509 default:
1510 break;
1511 }
1512 return sh;
1513}
1514
1519{
1521 if (d->widget) {
1523 d->widget->resize(event->newSize().toSize());
1524 }
1526}
1527
1532{
1535 if (!d->widget || !d->widget->isVisible())
1536 return;
1537
1538 // Filter out repaints on the window frame.
1539 const QRect exposedWidgetRect = (option->exposedRect & rect()).toAlignedRect();
1540 if (exposedWidgetRect.isEmpty())
1541 return;
1542
1543 // When rendering to pdf etc. painting may go outside widget boundaries unless clipped
1545 painter->setClipRect(d->widget->geometry(), Qt::IntersectClip);
1546
1547 d->widget->render(painter, exposedWidgetRect.topLeft(), exposedWidgetRect);
1548}
1549
1562{
1563 return Type;
1564}
1565
1581{
1582 QGraphicsProxyWidget *proxy = child->graphicsProxyWidget();
1583 if (proxy)
1584 return proxy;
1585 if (!child->parentWidget()) {
1586 qWarning("QGraphicsProxyWidget::createProxyForChildWidget: top-level widget not in a QGraphicsScene");
1587 return nullptr;
1588 }
1589
1590 QGraphicsProxyWidget *parentProxy = createProxyForChildWidget(child->parentWidget());
1591 if (!parentProxy)
1592 return nullptr;
1593
1594 if (!QMetaObject::invokeMethod(parentProxy, "newProxyWidget", Qt::DirectConnection,
1596 return nullptr;
1597 proxy->setParent(parentProxy);
1598 proxy->setWidget(child);
1599 return proxy;
1600}
1601
1624
1625
1626
1628
1629#include "moc_qgraphicsproxywidget.cpp"
static void dispatchEnterLeave(QWidget *enter, QWidget *leave, const QPointF &globalPosF)
static bool translateRawTouchEvent(QWidget *widget, const QTouchEvent *touchEvent)
static bool sendMouseEvent(QWidget *receiver, QMouseEvent *event, QWidget *alienWidget, QWidget *native, QWidget **buttonDown, QPointer< QWidget > &lastMouseReceiver, bool spontaneous=true, bool onlyDispatchEnterLeave=false)
The QContextMenuEvent class contains parameters that describe a context menu event.
Definition qevent.h:594
Reason
This enum describes the reason why the event was sent.
Definition qevent.h:597
static bool sendEvent(QObject *receiver, QEvent *event)
Sends event event directly to receiver receiver, using the notify() function.
\inmodule QtCore
Definition qcoreevent.h:45
Type
This enum type defines the valid event types in Qt.
Definition qcoreevent.h:51
@ GraphicsSceneMouseMove
Definition qcoreevent.h:189
@ EnabledChange
Definition qcoreevent.h:134
@ GraphicsSceneMouseRelease
Definition qcoreevent.h:191
@ ShortcutOverride
Definition qcoreevent.h:158
@ FocusOut
Definition qcoreevent.h:67
@ InputMethod
Definition qcoreevent.h:120
@ GraphicsSceneMousePress
Definition qcoreevent.h:190
@ StyleChange
Definition qcoreevent.h:136
@ LayoutRequest
Definition qcoreevent.h:112
@ FontChange
Definition qcoreevent.h:133
@ MouseMove
Definition qcoreevent.h:63
@ KeyPress
Definition qcoreevent.h:64
@ MouseButtonPress
Definition qcoreevent.h:60
@ TouchUpdate
Definition qcoreevent.h:242
@ TouchBegin
Definition qcoreevent.h:241
@ ToolTipChange
Definition qcoreevent.h:229
@ WindowActivate
Definition qcoreevent.h:83
@ GraphicsSceneMouseDoubleClick
Definition qcoreevent.h:192
@ PaletteChange
Definition qcoreevent.h:94
@ MouseButtonDblClick
Definition qcoreevent.h:62
@ GraphicsSceneHelp
Definition qcoreevent.h:197
@ WindowDeactivate
Definition qcoreevent.h:84
@ MouseButtonRelease
Definition qcoreevent.h:61
bool isAccepted() const
Definition qcoreevent.h:308
The QFocusEvent class contains event parameters for widget focus events.
Definition qevent.h:470
QVariant extra(Extra type) const
QGraphicsScene * scene
QList< QGraphicsItem * > children
QGraphicsItem * parent
The QGraphicsItem class is the base class for all graphical items in a QGraphicsScene.
virtual bool contains(const QPointF &point) const
Returns true if this item contains point, which is in local coordinates; otherwise,...
GraphicsItemChange
This enum describes the state changes that are notified by QGraphicsItem::itemChange().
virtual void wheelEvent(QGraphicsSceneWheelEvent *event)
This event handler, for event event, can be reimplemented to receive wheel events for this item.
void update(const QRectF &rect=QRectF())
Schedules a redraw of the area covered by rect in this item.
virtual void dragEnterEvent(QGraphicsSceneDragDropEvent *event)
This event handler, for event event, can be reimplemented to receive drag enter events for this item.
QGraphicsWidget * parentWidget() const
virtual void dropEvent(QGraphicsSceneDragDropEvent *event)
This event handler, for event event, can be reimplemented to receive drop events for this item.
bool isWindow() const
virtual void dragLeaveEvent(QGraphicsSceneDragDropEvent *event)
This event handler, for event event, can be reimplemented to receive drag leave events for this item.
bool isEnabled() const
Returns true if the item is enabled; otherwise, false is returned.
bool hasFocus() const
Returns true if this item is active, and it or its \l{focusProxy()}{focus proxy} has keyboard input f...
virtual void dragMoveEvent(QGraphicsSceneDragDropEvent *event)
This event handler, for event event, can be reimplemented to receive drag move events for this item.
void setEnabled(bool enabled)
If enabled is true, the item is enabled; otherwise, it is disabled.
virtual QVariant inputMethodQuery(Qt::InputMethodQuery query) const
This method is only relevant for input items.
void setVisible(bool visible)
If visible is true, the item is made visible.
bool isVisible() const
Returns true if the item is visible; otherwise, false is returned.
GraphicsItemFlags flags() const
Returns this item's flags.
QPointF mapFromScene(const QPointF &point) const
Maps the point point, which is in this item's scene's coordinate system, to this item's coordinate sy...
QPointF pos
the position of the item
QPointF mapToReceiver(const QPointF &pos, const QWidget *receiver) const
QPointer< QWidget > embeddedMouseGrabber
void setWidget_helper(QWidget *widget, bool autoShow)
QPointer< QWidget > lastWidgetUnderMouse
void sendWidgetKeyEvent(QKeyEvent *event)
QWidget * findFocusChild(QWidget *child, bool next) const
void sendWidgetMouseEvent(QGraphicsSceneMouseEvent *event)
void removeSubFocusHelper(QWidget *widget, Qt::FocusReason reason)
The QGraphicsProxyWidget class provides a proxy layer for embedding a QWidget in a QGraphicsScene.
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) override
\reimp
bool event(QEvent *event) override
\reimp
void focusInEvent(QFocusEvent *event) override
\reimp
void grabMouseEvent(QEvent *event) override
\reimp
void resizeEvent(QGraphicsSceneResizeEvent *event) override
\reimp
void hoverEnterEvent(QGraphicsSceneHoverEvent *event) override
\reimp
QGraphicsProxyWidget * createProxyForChildWidget(QWidget *child)
void hoverMoveEvent(QGraphicsSceneHoverEvent *event) override
\reimp
void showEvent(QShowEvent *event) override
\reimp
QVariant inputMethodQuery(Qt::InputMethodQuery query) const override
\reimp
QGraphicsProxyWidget(QGraphicsItem *parent=nullptr, Qt::WindowFlags wFlags=Qt::WindowFlags())
Constructs a new QGraphicsProxy widget.
void setWidget(QWidget *widget)
Embeds widget into this proxy widget.
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override
\reimp
QVariant itemChange(GraphicsItemChange change, const QVariant &value) override
\reimp
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) override
\reimp
void keyReleaseEvent(QKeyEvent *event) override
\reimp
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override
\reimp
QRectF subWidgetRect(const QWidget *widget) const
Returns the rectangle for widget, which must be a descendant of widget(), or widget() itself,...
void contextMenuEvent(QGraphicsSceneContextMenuEvent *event) override
\reimp
bool focusNextPrevChild(bool next) override
\reimp
bool eventFilter(QObject *object, QEvent *event) override
\reimp
void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override
\reimp
~QGraphicsProxyWidget()
Destroys the proxy widget and any embedded widget.
void keyPressEvent(QKeyEvent *event) override
\reimp
int type() const override
\reimp
void ungrabMouseEvent(QEvent *event) override
\reimp
QGraphicsProxyWidget * newProxyWidget(const QWidget *)
void inputMethodEvent(QInputMethodEvent *event) override
\reimp
void setGeometry(const QRectF &rect) override
\reimp
void focusOutEvent(QFocusEvent *event) override
\reimp
QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint=QSizeF()) const override
\reimp
void hideEvent(QHideEvent *event) override
\reimp
QWidget * widget() const
Returns a pointer to the embedded widget.
void mousePressEvent(QGraphicsSceneMouseEvent *event) override
\reimp
The QGraphicsSceneContextMenuEvent class provides context menu events in the graphics view framework.
The QGraphicsSceneDragDropEvent class provides events for drag and drop in the graphics view framewor...
void setTimestamp(quint64 ts)
The QGraphicsSceneHelpEvent class provides events when a tooltip is requested.
The QGraphicsSceneHoverEvent class provides hover events in the graphics view framework.
The QGraphicsSceneMouseEvent class provides mouse events in the graphics view framework.
void setButton(Qt::MouseButton button)
void setPos(const QPointF &pos)
void setButtons(Qt::MouseButtons buttons)
void setModifiers(Qt::KeyboardModifiers modifiers)
void setScreenPos(const QPoint &pos)
The QGraphicsSceneResizeEvent class provides events for widget resizing in the graphics view framewor...
The QGraphicsSceneWheelEvent class provides wheel events in the graphics view framework.
void removeItem(QGraphicsItem *item)
Removes the item item and all its children from the scene.
void resolveFont(uint inheritedMask) override
void resolvePalette(uint inheritedMask) override
The QGraphicsWidget class is the base class for all widget items in a QGraphicsScene.
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.
QStyle * style() const
Returns a pointer to the widget's style.
QRectF rect() const
Returns the item's local rect as a QRectF.
void setGeometry(const QRectF &rect) override
This virtual function sets the geometry of the QGraphicsLayoutItem to rect, which is in parent coordi...
bool event(QEvent *event) override
\reimp
QVariant itemChange(GraphicsItemChange change, const QVariant &value) override
\reimp
QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint=QSizeF()) const override
\reimp
bool testAttribute(Qt::WidgetAttribute attribute) const
Returns true if attribute is enabled for this widget; otherwise, returns false.
void updateGeometry() override
If this widget is currently managed by a layout, this function notifies the layout that the widget's ...
virtual void resizeEvent(QGraphicsSceneResizeEvent *event)
This event handler, for \l{QEvent::GraphicsSceneResize}{GraphicsSceneResize} events,...
QGraphicsWidget * focusWidget() const
If this widget, a child or descendant of this widget currently has input focus, this function will re...
static QInputMethod * inputMethod()
returns the input method.
The QHelpEvent class provides an event that is used to request helpful information about a particular...
Definition qevent.h:788
The QHideEvent class provides an event which is sent after a widget is hidden.
Definition qevent.h:586
The QInputMethodEvent class provides parameters for input method events.
Definition qevent.h:625
The QKeyEvent class describes a key event.
Definition qevent.h:424
Qt::KeyboardModifiers modifiers() const
Returns the keyboard modifier flags that existed immediately after the event occurred.
Definition qevent.cpp:1468
int key() const
Returns the code of the key that was pressed or released.
Definition qevent.h:434
virtual QWidget * widget() const
If this item manages a QWidget, returns that widget.
The QLayout class is the base class of geometry managers.
Definition qlayout.h:26
\inmodule QtGui
Definition qevent.h:196
\inmodule QtCore
Definition qobject.h:103
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
Definition qobject.cpp:2960
virtual bool eventFilter(QObject *watched, QEvent *event)
Filters events if this object has been installed as an event filter for the watched object.
Definition qobject.cpp:1555
static bool disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *member)
\threadsafe
Definition qobject.cpp:3236
void removeEventFilter(QObject *obj)
Removes an event filter object obj from this object.
Definition qobject.cpp:2370
void destroyed(QObject *=nullptr)
This signal is emitted immediately before the object obj is destroyed, after any instances of QPointe...
virtual int devType() const
The QPainter class performs low-level painting on widgets and other paint devices.
Definition qpainter.h:46
QPaintDevice * device() const
Returns the paint device on which this painter is currently painting, or \nullptr if the painter is n...
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.
\inmodule QtCore\reentrant
Definition qpoint.h:217
constexpr QPoint toPoint() const
Rounds the coordinates of this point to the nearest integer, and returns a QPoint object with the rou...
Definition qpoint.h:404
\inmodule QtCore\reentrant
Definition qpoint.h:25
constexpr void setY(int y) noexcept
Sets the y coordinate of this point to the given y coordinate.
Definition qpoint.h:145
constexpr void setX(int x) noexcept
Sets the x coordinate of this point to the given x coordinate.
Definition qpoint.h:140
void setTimestamp(quint64 timestamp) override
Definition qevent.cpp:338
T * data() const noexcept
Definition qpointer.h:73
bool isNull() const noexcept
Definition qpointer.h:84
static const QPointingDevice * primaryPointingDevice(const QString &seatName=QString())
Returns the primary pointing device (the core pointer, traditionally assumed to be a mouse) on the gi...
\inmodule QtCore\reentrant
Definition qrect.h:484
constexpr QPointF topLeft() const noexcept
Returns the position of the rectangle's top-left corner.
Definition qrect.h:511
\inmodule QtCore\reentrant
Definition qrect.h:30
The QShowEvent class provides an event that is sent when a widget is shown.
Definition qevent.h:578
\inmodule QtCore
Definition qsize.h:208
\inmodule QtCore
Definition qsize.h:25
constexpr bool isNull() const noexcept
Returns true if both the width and height is 0; otherwise returns false.
Definition qsize.h:121
constexpr bool isValid() const noexcept
Returns true if both the width and height is equal to or greater than 0; otherwise returns false.
Definition qsize.h:127
The QStyleOptionGraphicsItem class is used to describe the parameters needed to draw a QGraphicsItem.
The QTouchEvent class contains parameters that describe a touch event.
Definition qevent.h:917
\inmodule QtCore
Definition qvariant.h:65
uint inheritedFontResolveMask
Definition qwidget_p.h:690
QPalette::ResolveMask inheritedPaletteResolveMask
Definition qwidget_p.h:692
void resolvePalette()
Definition qwidget.cpp:4597
void resolveFont()
Definition qwidget.cpp:4761
The QWidget class is the base class of all user interface objects.
Definition qwidget.h:99
void setAttribute(Qt::WidgetAttribute, bool on=true)
Sets the attribute attribute on this widget if on is true; otherwise clears the attribute.
QSize size
the size of the widget excluding any window frame
Definition qwidget.h:113
QRect geometry
the geometry of the widget relative to its parent and excluding the window frame
Definition qwidget.h:106
QWidget * childAt(int x, int y) const
Returns the visible child widget at the position ({x}, {y}) in the widget's coordinate system.
Definition qwidget.h:798
QWidget * previousInFocusChain() const
The previousInFocusChain function returns the previous widget in this widget's focus chain.
Definition qwidget.cpp:6859
QPoint pos
the position of the widget within its parent widget
Definition qwidget.h:111
void unsetCursor()
Definition qwidget.cpp:4983
QWidget * focusWidget() const
Returns the last child of this widget that setFocus had been called on.
Definition qwidget.cpp:6828
void setFocus()
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qwidget.h:423
void update()
Updates the widget unless updates are disabled or the widget is hidden.
QSize sizeHint
the recommended size for the widget
Definition qwidget.h:148
QStyle * style() const
Definition qwidget.cpp:2600
QWidget * parentWidget() const
Returns the parent of this widget, or \nullptr if it does not have any parent widget.
Definition qwidget.h:904
QCursor cursor
the cursor shape for this widget
Definition qwidget.h:135
QPointF mapTo(const QWidget *, const QPointF &) const
Translates the widget coordinate pos to the coordinate system of parent.
Definition qwidget.cpp:4197
bool isWindow() const
Returns true if the widget is an independent window, otherwise returns false.
Definition qwidget.h:811
bool isAncestorOf(const QWidget *child) const
Returns true if this widget is a parent, (or grandparent and so on to any level), of the given child,...
Definition qwidget.cpp:8822
bool isVisible() const
Definition qwidget.h:874
QPointF mapFromGlobal(const QPointF &) const
Translates the global screen coordinate pos to widget coordinates.
bool testAttribute(Qt::WidgetAttribute) const
Returns true if attribute attribute is set on this widget; otherwise returns false.
Definition qwidget.h:910
QOpenGLWidget * widget
[1]
rect
[4]
short next
Definition keywords.cpp:445
Combined button and popup list for selecting options.
InputMethodQuery
@ NoButton
Definition qnamespace.h:57
@ WA_WState_ExplicitShowHide
Definition qnamespace.h:335
@ WA_SetCursor
Definition qnamespace.h:305
@ WA_Resized
Definition qnamespace.h:308
@ WA_QuitOnClose
Definition qnamespace.h:342
@ WA_DontShowOnScreen
Definition qnamespace.h:383
@ WA_SetStyle
Definition qnamespace.h:356
@ WA_WState_Hidden
Definition qnamespace.h:297
@ WA_NoSystemBackground
Definition qnamespace.h:291
@ WA_InputMethodEnabled
Definition qnamespace.h:295
@ WA_OpaquePaintEvent
Definition qnamespace.h:287
@ IntersectClip
@ WheelFocus
Definition qnamespace.h:111
@ TabFocus
Definition qnamespace.h:108
@ StrongFocus
Definition qnamespace.h:110
@ Horizontal
Definition qnamespace.h:99
@ MouseEventSynthesizedByQt
@ Key_Tab
Definition qnamespace.h:664
@ Key_Backtab
Definition qnamespace.h:665
@ ControlModifier
@ AltModifier
@ IgnoreAction
@ DirectConnection
@ ScrollBegin
@ NoScrollPhase
@ MaximumSize
@ PreferredSize
@ MinimumDescent
@ MinimumSize
FocusReason
@ BacktabFocusReason
@ TabFocusReason
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
Q_WIDGETS_EXPORT bool qt_tab_all_widgets()
bool qt_sendSpontaneousEvent(QObject *, QEvent *)
#define qDebug
[1]
Definition qlogging.h:164
#define qWarning
Definition qlogging.h:166
#define SLOT(a)
Definition qobjectdefs.h:52
#define Q_RETURN_ARG(Type, data)
Definition qobjectdefs.h:64
#define Q_ARG(Type, data)
Definition qobjectdefs.h:63
#define SIGNAL(a)
Definition qobjectdefs.h:53
GLsizei const GLfloat * v
[13]
GLenum type
GLint GLint GLint GLint GLint GLint GLint GLbitfield mask
struct _cl_event * event
GLenum query
GLuint res
GLdouble GLdouble GLdouble GLdouble q
Definition qopenglext.h:259
GLfloat GLfloat p
[1]
GLuint GLenum option
decorationRoleName setToolTip
#define Q_ASSERT(cond)
Definition qrandom.cpp:47
#define Q_ASSERT_X(cond, x, msg)
Definition qrandom.cpp:48
#define Q_UNUSED(x)
unsigned int uint
Definition qtypes.h:34
#define QWIDGETSIZE_MAX
Definition qwidget.h:917
static bool bypassGraphicsProxyWidget(const QWidget *p)
Definition qwidget_p.h:169
QObject::connect nullptr
QLayoutItem * child
[0]
QPainter painter(this)
[7]
QNetworkProxy proxy
[0]
static bool invokeMethod(QObject *obj, const char *member, Qt::ConnectionType, QGenericReturnArgument ret, QGenericArgument val0=QGenericArgument(nullptr), QGenericArgument val1=QGenericArgument(), QGenericArgument val2=QGenericArgument(), QGenericArgument val3=QGenericArgument(), QGenericArgument val4=QGenericArgument(), QGenericArgument val5=QGenericArgument(), QGenericArgument val6=QGenericArgument(), QGenericArgument val7=QGenericArgument(), QGenericArgument val8=QGenericArgument(), QGenericArgument val9=QGenericArgument())
\threadsafe This is an overloaded member function, provided for convenience. It differs from the abov...