×

Discussion Board

Results 1 to 3 of 3
  1. #1
    Registered User
    Join Date
    Aug 2009
    Posts
    12

    Redirect mouse events from a dialog to its parent

    Hi,

    I'm trying to re-implement the mousePress event handler in a dialog, and send the events received by it to its parent widget.

    I've tryied posting the event to the parent QObject (a widget), and also sending the event (QApplication::sendEvent), but with no success.

    Code:
    void MyDialog::mousePressEvent(QMouseEvent *event) {
        this->close();
        QApplication::postEvent(this->parent, event);
    }
    The idea is that when the dialog receives a mousePressEvent, it closes itself and forwards the mouse event to the parent widget .

    Any suggestions?

    Thanks in advance,
    JCC.

  2. #2
    Super Contributor
    Join Date
    Nov 2009
    Location
    Minnesota, USA
    Posts
    3,209

    Re: Redirect mouse events from a dialog to its parent

    If you ignore() a mousePressEvent, it's automatically passed to the parent.

  3. #3
    Registered User
    Join Date
    Aug 2009
    Posts
    12

    Re: Redirect mouse events from a dialog to its parent

    Thanks danhicksbyron!
    Great info!

Similar Threads

  1. Replies: 12
    Last Post: 2011-03-29, 16:38
  2. How to make widget grow outside of its parent widget
    By supermanfg in forum [Archived] Qt SDKs and Tools
    Replies: 3
    Last Post: 2010-01-09, 11:07
  3. question with dispatching mouse events to svg element
    By fanhaipeng in forum Mobile Java Media (Graphics & Sounds)
    Replies: 0
    Last Post: 2009-12-25, 16:34
  4. Passing Unhandled Key Events to Container or Parent - possible?
    By marquk in forum Symbian User Interface
    Replies: 1
    Last Post: 2009-01-30, 16:07

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×