Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. The tootip of QToolButton does not appear when hover into the button by WinAPI instead of Physical Mouse
Forum Updated to NodeBB v4.3 + New Features

The tootip of QToolButton does not appear when hover into the button by WinAPI instead of Physical Mouse

Scheduled Pinned Locked Moved Unsolved Qt for Python
4 Posts 2 Posters 406 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    Trong Le
    wrote on last edited by Trong Le
    #1

    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.

    1.png

    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,

    T 1 Reply Last reply
    0
    • T Trong Le

      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.

      1.png

      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,

      T Offline
      T Offline
      Trong Le
      wrote on last edited by Trong Le
      #2

      @Trong-Le I forgot note that Iam working on PyQt 5.15.2 x64

      kkoehneK 1 Reply Last reply
      0
      • T Trong Le

        @Trong-Le I forgot note that Iam working on PyQt 5.15.2 x64

        kkoehneK Offline
        kkoehneK Offline
        kkoehne
        Moderators
        wrote on last edited by
        #3

        @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);
                    }
        

        Director R&D, The Qt Company

        T 1 Reply Last reply
        0
        • kkoehneK kkoehne

          @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);
                      }
          
          T Offline
          T Offline
          Trong Le
          wrote on last edited by
          #4

          @kkoehne Many thanks, I will check more in object events.

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved