Show positions in QDebug operator<<(dbg, QHoverEvent*)
In Qt 6, QHoverEvent is a QSinglePointEvent and carries more information than it did in Qt 5. Task-number: QTBUG-94971 Change-Id: I55b271e8741081ed9074f687b08f4111142a1bf0 Pick-to: 6.2 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
This commit is contained in:
parent
f100d412b4
commit
f5b76be1e4
@ -4026,6 +4026,7 @@ QDebug operator<<(QDebug dbg, const QEvent *e)
|
|||||||
}
|
}
|
||||||
// More useful event output could be added here
|
// More useful event output could be added here
|
||||||
const QEvent::Type type = e->type();
|
const QEvent::Type type = e->type();
|
||||||
|
bool isMouse = false;
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case QEvent::Expose:
|
case QEvent::Expose:
|
||||||
QT_WARNING_PUSH
|
QT_WARNING_PUSH
|
||||||
@ -4044,31 +4045,41 @@ QT_WARNING_POP
|
|||||||
case QEvent::NonClientAreaMouseMove:
|
case QEvent::NonClientAreaMouseMove:
|
||||||
case QEvent::NonClientAreaMouseButtonRelease:
|
case QEvent::NonClientAreaMouseButtonRelease:
|
||||||
case QEvent::NonClientAreaMouseButtonDblClick:
|
case QEvent::NonClientAreaMouseButtonDblClick:
|
||||||
|
isMouse = true;
|
||||||
|
Q_FALLTHROUGH();
|
||||||
|
case QEvent::HoverEnter:
|
||||||
|
case QEvent::HoverMove:
|
||||||
|
case QEvent::HoverLeave:
|
||||||
{
|
{
|
||||||
const QMouseEvent *me = static_cast<const QMouseEvent*>(e);
|
const QSinglePointEvent *spe = static_cast<const QSinglePointEvent*>(e);
|
||||||
const Qt::MouseButton button = me->button();
|
const Qt::MouseButton button = spe->button();
|
||||||
const Qt::MouseButtons buttons = me->buttons();
|
const Qt::MouseButtons buttons = spe->buttons();
|
||||||
dbg << "QMouseEvent(";
|
dbg << eventClassName(type) << '(';
|
||||||
QtDebugUtils::formatQEnum(dbg, type);
|
QtDebugUtils::formatQEnum(dbg, type);
|
||||||
if (type != QEvent::MouseMove && type != QEvent::NonClientAreaMouseMove) {
|
if (isMouse) {
|
||||||
dbg << ' ';
|
if (type != QEvent::MouseMove && type != QEvent::NonClientAreaMouseMove) {
|
||||||
QtDebugUtils::formatQEnum(dbg, button);
|
dbg << ' ';
|
||||||
|
QtDebugUtils::formatQEnum(dbg, button);
|
||||||
|
}
|
||||||
|
if (buttons && button != buttons) {
|
||||||
|
dbg << " btns=";
|
||||||
|
QtDebugUtils::formatQFlags(dbg, buttons);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (buttons && button != buttons) {
|
QtDebugUtils::formatNonNullQFlags(dbg, ", ", spe->modifiers());
|
||||||
dbg << " btns=";
|
|
||||||
QtDebugUtils::formatQFlags(dbg, buttons);
|
|
||||||
}
|
|
||||||
QtDebugUtils::formatNonNullQFlags(dbg, ", ", me->modifiers());
|
|
||||||
dbg << " pos=";
|
dbg << " pos=";
|
||||||
QtDebugUtils::formatQPoint(dbg, me->position());
|
QtDebugUtils::formatQPoint(dbg, spe->position());
|
||||||
dbg << " scn=";
|
dbg << " scn=";
|
||||||
QtDebugUtils::formatQPoint(dbg, me->scenePosition());
|
QtDebugUtils::formatQPoint(dbg, spe->scenePosition());
|
||||||
dbg << " gbl=";
|
dbg << " gbl=";
|
||||||
QtDebugUtils::formatQPoint(dbg, me->globalPosition());
|
QtDebugUtils::formatQPoint(dbg, spe->globalPosition());
|
||||||
dbg << " dev=" << me->device() << ')';
|
dbg << " dev=" << spe->device() << ')';
|
||||||
if (me->source() != Qt::MouseEventNotSynthesized) {
|
if (isMouse) {
|
||||||
dbg << " source=";
|
auto src = static_cast<const QMouseEvent*>(e)->source();
|
||||||
QtDebugUtils::formatQEnum(dbg, me->source());
|
if (src != Qt::MouseEventNotSynthesized) {
|
||||||
|
dbg << " source=";
|
||||||
|
QtDebugUtils::formatQEnum(dbg, src);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user