Results 1 to 6 of 6

Thread: QPushButton mouse events

  1. #1
    Join Date
    Jan 2006
    Posts
    21
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default QPushButton mouse events

    Something that's irritating me slightly:
    In an application I'm writing, I've subclassed QPushButton to add a mouseMoved() signal. However, there's a tiny border around the edge of the button, about a pixel on every side, where the mouse doesn't trigger QPushButton::mouseMoveEvent(); yet, if the user clicks, clicked() and friends are emitted. Is there any way around this?

  2. #2
    Join Date
    Jan 2006
    Location
    Frankfurt
    Posts
    500
    Thanks
    1
    Thanked 52 Times in 52 Posts
    Platforms
    MacOS X Unix/X11

    Default Re: QPushButton mouse events

    Are you sure that this is a border and not a 1px area that is maybe caused by the fact that a move from outside in the first pixel of the button is not realy a move but a mouseEnter? You can test this by moving the mouse in this border, maybe up and down in the left or right border. If you get mouseEnter and mouseLeave-events for the cases you miss a mouseMoveEvent, you can just use these.
    It's nice to be important but it's more important to be nice.

  3. #3
    Join Date
    Jan 2006
    Posts
    21
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: QPushButton mouse events

    Aha. That was indeed the problem. Overriding enterEvent(QEvent*) worked. Thank you.

  4. #4
    Join Date
    Jan 2006
    Posts
    21
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: QPushButton mouse events

    A similar problem: what about accepting mouse events if the button(s) is/are held down? When the buttons are held down as the mouse enters the widget, it seems no events are fired; even hasMouse() returns false. I've tried the drag* events, but no joy.
    Last edited by Twey; 15th January 2006 at 14:08.

  5. #5
    Join Date
    Jan 2006
    Location
    Frankfurt
    Posts
    500
    Thanks
    1
    Thanked 52 Times in 52 Posts
    Platforms
    MacOS X Unix/X11

    Default Re: QPushButton mouse events

    I think the widget where you actually pressed the mouse gets exclusive all mouseEvents until you release the mouse. For example, you can press the mouse over a QSlider or QDial and leave the widget but you are still able to set the value of the slider or dial until you release the mouse again.
    It's nice to be important but it's more important to be nice.

  6. #6
    Join Date
    Jan 2006
    Posts
    21
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: QPushButton mouse events

    Yes. And there is no way around this?

Similar Threads

  1. Mouse events in QGraphicsPixmapItem and QGraphicsTextItem
    By manojmka in forum Qt Programming
    Replies: 3
    Last Post: 8th August 2008, 12:38
  2. QGraphicsView Mouse Events
    By tomf in forum Qt Programming
    Replies: 5
    Last Post: 29th July 2008, 16:03
  3. QPushButton:: Handle right mouse button events. Easyway?
    By Harvey West in forum Qt Programming
    Replies: 6
    Last Post: 28th February 2007, 17:56
  4. mouse moving don't produce mouse events
    By coralbird in forum Qt Programming
    Replies: 1
    Last Post: 13th September 2006, 07:13
  5. QStackerWidget and mouse events
    By high_flyer in forum Qt Programming
    Replies: 3
    Last Post: 25th April 2006, 20: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.