Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8168501
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T20:32:54+00:00 2026-06-06T20:32:54+00:00

I just noticed that moving the mouse cursor across a tooltip does not seem

  • 0

I just noticed that moving the mouse cursor across a tooltip does not seem to return a mouseMoveEvent in PySide.

In my case it causes trouble as I am dynamically displaying a mini-icon on top of a main icon when the mouse moves over the main icon area, and hiding the mini-icon again when the mouse leaves the main icon area. So if the user moves the mouse cursor across a large tooltip and then ends up outside the main button area, the mouse event never registered the new position and the mini-icon stays visible, even though the mouse is no longer over the main icon area.

I guess I could work around this problem by creating a custom QToolTip and positioning it away from the main button area, so it’s never possible to leave the main button area via the tooltip. But that seems ugly.

Does anybody have an idea how to make the tooltip register with mouseMoveEvent so thie can be avoided?

Here is an example snippet (hope it will be formatted right, I have never posted here before):

import sys
from PySide.QtGui import *
from PySide.QtCore import *

class FancyButtonSmall( QWidget ):

    def __init__( self, parent=None ):
        super( FancyButtonSmall, self ).__init__( parent )
        self.setMouseTracking( True ) # TO DISPLAY "REMOVE" ICON ON MOUSE OVER

        # LAYOUT
        layout = QVBoxLayout()
        layout.setSpacing( 0 )
        self.setLayout( layout )
        self.setSizePolicy( QSizePolicy.Fixed, QSizePolicy.Fixed )
        self.fixedSize = ( 80, 80 )

        # BUTTON AND MOUSE STATE
        self.mainButtonDown = False # TO DRAW ICON STATE PROPERLY
        self.removeButtonDown = False # TO DRAW ICON STATE PROPERLY
        self.mouseOver = False # TO DISPLAY DELETE ICON

        # BUTTON COLOURS
        self.widgetColMainUp = QColor(60, 60, 60, 0)

        # LABELS
        self.textCol = QColor( 150, 150, 150 )

        # TOOLTIP
        self.setToolTip( self.__wrapText( 100*'test ' ) )


    def __wrapText( self, text, maxChar = 50 ):
        '''wrap text to only contain maxChar per line'''
        i = 1
        charList = list( text )
        while i*maxChar < len( charList ):
            charList.insert( i*maxChar, '\n' )
            i += 1
        return ''.join( charList )


    def mouseMoveEvent( self, event ):
        '''Show remove icon if cursor is on top of main icon'''
        print event.pos()

        self.mouseOver = self.iconRect.contains( event.pos() ) or self.removeIconRect.contains( event.pos() )
        self.update()

    def paintEvent( self, event ):
        painter = QPainter( self )
        painter.setRenderHint( QPainter.Antialiasing )

        # ICONS
        self.mainRect = QRect( 0, 0, self.geometry().width(), self.geometry().height() )
        iconSize = QSize( 58,58 )
        iconPos = QPoint( ( self.mainRect.width()-iconSize.width())/2, 10 )
        self.iconRect = QRect( iconPos, iconSize)

        removeIconSize = QSize( 16, 16 )
        removeIconPos = QPoint( iconSize.width()+iconPos.x()-10, iconPos.y()-5 )
        self.removeIconRect = QRect( removeIconPos, removeIconSize )

        # DRAW ICONS
        self.drawIcon( painter, iconPos, iconSize )

        # DRAW REMOVE ICON
        if self.mouseOver:
            self.drawIcon( painter, removeIconPos, removeIconSize, 'remove' )

    def drawIcon( self, painter, pos, size, btn='main' ):
        '''Draw icon with status'''
        painter.drawRect( pos.x(), pos.y(), size.width(), size.height() )

    def minimumSizeHint( self ):
        return QSize( *self.fixedSize )

    def sizeHint( self ):
        return QSize( *self.fixedSize )

if __name__ == '__main__':
    import os
    app = QApplication( sys.argv )
    w = QWidget()
    w.setLayout( QGridLayout() )
    btn2 = FancyButtonSmall()

    w.layout().addWidget( btn2, 1, 0 )

    w.show()
    sys.exit( app.exec_() )
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T20:32:57+00:00Added an answer on June 6, 2026 at 8:32 pm

    One of those moments where the answer becomes apparent right after asking: using enterEvent() and leaveEvent() instead of mouseMoveEvent() works a treat.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just noticed that java.beans.Introspector getBeanInfo does not pickup any superinterface's properties. Example: public
I have just noticed that my ViewController does not call init (See below) when
I just noticed that say http://s7.addthis.com/js/250/addthis_widget.js#pub=PUBID does the equivalent of http://s7.addthis.com/js/250/addthis_widget.js?pub=fct-250 but is much
I just created a web service client using axis and eclipse that does not
I just noticed that WPF textboxes bound to numeric data do not fire Property
I just noticed that the return list for results is limited to 1000. I
I just noticed that for vector push_back it is push back a reference to
I just noticed that if I have an identity column in a table, when
I've just noticed that if I do a MySQL request like this one: SELECT
I've just noticed that Webkit now has some support regarding the CSS Values and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.