Results 1 to 3 of 3

Thread: Determining when mouse over widget without events

  1. #1
    Join Date
    Nov 2007
    Posts
    5
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Determining when mouse over widget without events

    I have an application in which I have a settings dialog. The dialog is application modal. The dialog is composed of a tabbed widget.

    In the dialog I have the usual stuff; QLabels, QComboBoxes, QPushButtons, QLineEdits. I also have an empty space in the dialog consisting of a QLabel. What I want to do is this: When the mouse cursor enters an object area (QLabel, QPushButton etc...), I would like the empty QLabel space to show the whatsThis of the object.

    I wouldn't want to derive my own classes for all the objects in the dialog just to be able to implement enterEvent() and leaveEvent(). So is there another "easy" way to go about this? I guess I could probably somehow keep track of the mouse movements and constantly test whether the mouse is inside which widget, but that certainly doesn't seem like a simple solution.

  2. #2
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Determining when mouse over widget without events

    See QWidget::underMouse(). You could reimplement the mouseMoveEvent for the dialog and test this in there for all the widgets.

    Another solution is to install the tooltip label as event filter for all the other widgets and when the mouse enters one of them you display the label.

  3. #3
    Join Date
    Nov 2007
    Posts
    5
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Determining when mouse over widget without events

    An event filter, yes. So simple. Thanks.

Similar Threads

  1. Weird behaviour of mouse events and QMenu pop-ups
    By Ishark in forum Qt Programming
    Replies: 1
    Last Post: 7th August 2007, 07:46
  2. Handling Mouse Events of a parent widget
    By dvmorris in forum Qt Programming
    Replies: 2
    Last Post: 28th March 2007, 18:44
  3. mouse moving don't produce mouse events
    By coralbird in forum Qt Programming
    Replies: 1
    Last Post: 13th September 2006, 06:13
  4. QStackerWidget and mouse events
    By high_flyer in forum Qt Programming
    Replies: 3
    Last Post: 25th April 2006, 19:25
  5. Forwarding mouse events to another widget.
    By yogeshm02 in forum Qt Programming
    Replies: 8
    Last Post: 28th February 2006, 13:25

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.