The tootip of QToolButton does not appear when hover into the button by WinAPI instead of Physical Mouse
Unsolved
Qt for Python
-
I use WinAPI to move mouse and hover into QToolButton but its tooltip does not appear. My code is below:
int moveMouseToEx_win ( const int& nX , const int& nY ) { // Get current screen size double fScreenWidth = ::GetSystemMetrics ( SM_CXSCREEN ) - 1 ; double fScreenHeight = ::GetSystemMetrics ( SM_CYSCREEN ) - 1 ; // Translate it into mouse coordinate double fX = nX * ( 65535.0f / fScreenWidth ) ; double fY = nY * ( 65535.0f / fScreenHeight ) ; // Initialize a mouse input struct INPUT mouseInput ; ::SecureZeroMemory ( &mouseInput , sizeof(INPUT) ) ; mouseInput.type = INPUT_MOUSE ; mouseInput.mi.dwFlags = MOUSEEVENTF_MOVE | MOUSEEVENTF_ABSOLUTE ; mouseInput.mi.dx = (long)fX ; mouseInput.mi.dy = (long)fY ; return sendInput(&mouseInput,1); }
However, I see that the mouse is already on the button but its tooltip does not appear.
I tried with physcal mouse and it works normaly. Iam working on Qt 5.15.2 x64
Please support me to solve this issue.Regards,
-
@Trong-Le Don't know the answer, but the code that triggers the tooltip to show eventually is in QApplication::notify. You could try and see whether (and which which attributes the mouse move event is delivered to the application by e.g. calling a custom event handler on the QApplication object (see QObject.installEventFilter).
case QEvent::MouseMove: { QMouseEvent* mouse = static_cast<QMouseEvent*>(e); QPoint relpos = mouse->position().toPoint(); if (e->spontaneous()) { // ... if (e->type() == QEvent::MouseMove && mouse->buttons() == 0 && w->rect().contains(relpos)) { // Outside due to mouse grab? d->toolTipWidget = w; d->toolTipPos = relpos; d->toolTipGlobalPos = mouse->globalPosition().toPoint(); QStyle *s = d->toolTipWidget->style(); int wakeDelay = s->styleHint(QStyle::SH_ToolTip_WakeUpDelay, nullptr, d->toolTipWidget, nullptr); d->toolTipWakeUp.start(d->toolTipFallAsleep.isActive() ? 20 : wakeDelay, this); }