11#include <QtGui/private/qguiapplication_p.h>
13#include <QtCore/qloggingcategory.h>
14#include <QtGui/private/qeventpoint_p.h>
15#include <QtQuick/private/qquickitem_p.h>
16#include <QtQuick/private/qquickwindowmodule_p.h>
17#include <QtQuick/private/qquickwindowmodule_p_p.h>
18#include <qpa/qplatformwindow_p.h>
32 void forwardEventToParentMenuOrMenuBar(
QEvent *
event);
41 d->m_popupItem =
popup->popupItem();
42 setTransientParent(
parent);
50 setWidth(
d->m_popupItem->implicitWidth());
61 qCDebug(lcPopupWindow) <<
"Created popup window with flags: " <<
flags;
90 handlePopupPositionChangeFromWindowSystem(e->
pos());
101 qCDebug(lcPopupWindow) <<
"A window system event changed the popup's size to be " << e->
size();
121 if (!
event->isPointerEvent())
123 auto menu = qobject_cast<QQuickMenu *>(
q->popup());
128 const QPointF globalPos = pe->points().first().globalPosition();
136 if (
auto parentMenu = qobject_cast<QQuickMenu *>(menuParent)) {
140 if (popup_d->contains(scenePos)) {
141 targetPopupWindow = popupWindow;
142 targetWindow = popupWindow;
145 }
else if (
auto menuBar = qobject_cast<QQuickMenuBar *>(menuParent)) {
147 if (
menuBar->contains(menuBarPos))
152 menuParent = menuParent->
parent();
155 if (!targetPopupWindow) {
156 if (pe->isBeginEvent()) {
168 if (pe->isUpdateEvent()){
170 const auto scenePos = pe->point(0).scenePosition();
171 const auto translatedScenePos = targetWindow->mapFromGlobal(globalPos);
172 QMutableEventPoint::setScenePosition(pe->point(0), translatedScenePos);
173 auto *grabber = pe->exclusiveGrabber(pe->point(0));
180 pe->setExclusiveGrabber(pe->point(0),
nullptr);
183 qCDebug(lcPopupWindow) <<
"forwarding" << pe <<
"to popup menu:" << targetWindow;
187 QMutableEventPoint::setScenePosition(pe->point(0), scenePos);
189 pe->setExclusiveGrabber(pe->point(0), grabber);
190 }
else if (pe->isEndEvent()) {
194 if (targetPopupWindow)
202 d->forwardEventToParentMenuOrMenuBar(e);
225void QQuickPopupWindow::parentWindowXChanged(
int newX)
227 const auto popupLocalPos = global2Local({
x(),
y()});
228 handlePopupPositionChangeFromWindowSystem({newX + popupLocalPos.x(),
y()});
231void QQuickPopupWindow::parentWindowYChanged(
int newY)
233 const auto popupLocalPos = global2Local({
x(),
y()});
234 handlePopupPositionChangeFromWindowSystem({
x(), newY + popupLocalPos.y()});
237void QQuickPopupWindow::handlePopupPositionChangeFromWindowSystem(
const QPoint &
pos)
245 const auto windowPos = global2Local(
pos);
246 qCDebug(lcPopupWindow) <<
"A window system event changed the popup's position to be " << windowPos;
247 popupPrivate->setEffectivePosFromWindowPos(windowPos);
250void QQuickPopupWindow::implicitWidthChanged()
253 if (
auto popup =
d->m_popup)
257void QQuickPopupWindow::implicitHeightChanged()
260 if (
auto popup =
d->m_popup)
static bool closeAllPopups()
Returns true if there are no more open popups.
The QHideEvent class provides an event which is sent after a widget is hidden.
constexpr qreal right() const noexcept
Returns the right margin.
constexpr qreal left() const noexcept
Returns the left margin.
constexpr qreal top() const noexcept
Returns the top margin.
constexpr qreal bottom() const noexcept
Returns the bottom margin.
The QMoveEvent class contains event parameters for move events.
const QPoint & pos() const
Returns the new position of the widget.
QObject * parent() const
Returns a pointer to the parent object.
\inmodule QtCore\reentrant
constexpr QPoint toPoint() const
Rounds the coordinates of this point to the nearest integer, and returns a QPoint object with the rou...
\inmodule QtCore\reentrant
A base class for pointer events.
QPointF mapFromScene(const QPointF &point) const
Maps the given point in the scene's coordinate system to the equivalent point within this item's coor...
static QQuickWindowPrivate * get(QQuickWindow *c)
bool event(QEvent *) override
\reimp
\qmltype Window \instantiates QQuickWindow \inqmlmodule QtQuick
QQuickItem * contentItem
\qmlattachedproperty Item Window::contentItem
void hideEvent(QHideEvent *) override
\reimp
The QResizeEvent class contains event parameters for resize events.
const QSize & size() const
Returns the new size of the widget.
constexpr int height() const noexcept
Returns the height.
constexpr int width() const noexcept
Returns the width.
Qt::WindowFlags flags
the window flags of the window
virtual void resizeEvent(QResizeEvent *)
Override this to handle resize events (ev).
constexpr QColor Transparent
Combined button and popup list for selecting options.
#define qCDebug(category,...)
#define Q_STATIC_LOGGING_CATEGORY(name,...)
GLdouble GLdouble GLdouble GLdouble q
connect(quitButton, &QPushButton::clicked, &app, &QCoreApplication::quit, Qt::QueuedConnection)
myObject disconnect()
[26]
myFilter setColor(QColor(128, 0, 0))