Results 1 to 3 of 3

Thread: Find what event is triggered on an action

  1. #1
    Join Date
    Sep 2015
    Location
    Ontario, Canada
    Posts
    28
    Thanks
    12
    Thanked 1 Time in 1 Post
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Find what event is triggered on an action

    I've made a class (inherited QMainWindow - I'll call it MyMainWindow here) where I've reimplemented the dropEvent and the mousePressEvents in order to let me re-parent QDockWidgets by dragging and dropping them between different instances of MyMainWindow. It currently re-parents them fine, except after re-parenting them it doesn't go straight to letting the user choose where to dock the re-parented QDockWidget on the MyMainWindow like I was hoping it would.

    I found however that it will do this after I move my mouse over the top left corner of the MyMainWindow object's dock. I wanted to know if there was a way that I could capture what events are occurring so when I mouseover the top left of the widget I could find what signal it was and manually trigger it at the end of my dropEvent.

    Alternatively if there was a way to manually call the function that lets a user move where a QDockWidget is docked that would also work.

    Thanks

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Find what event is triggered on an action

    You can see all events going to an object by installing an event filter on that opject.
    You can see all events by installing an event filter on the application object.

    It might also be useful, maybe even more than tracking events, to look at the code of QMainWindow.

    Cheers,
    _

  3. The following user says thank you to anda_skoa for this useful post:

    TEAmerc (1st October 2015)

  4. #3
    Join Date
    Sep 2015
    Location
    Ontario, Canada
    Posts
    28
    Thanks
    12
    Thanked 1 Time in 1 Post
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Find what event is triggered on an action

    Thanks for the response! Also if I want to trigger an event would all I have to do be something like this:

    Qt Code:
    1. QEvent reParentEvent(QEvent::LayoutRequest); // Widget layout needs to be redone - Type 76
    2. QApplication::sendEvent(this, &reParentEvent);
    To copy to clipboard, switch view to plain text mode 

    Or is there something more to send because so far I haven't been able to make the fix and I'm not sure if I haven't gotten the correct event (there's 3 likely ones, but I may be wrong as there's a lot of events being passed) or if I'm not triggering the event properly.


    Added after 39 minutes:


    Nevermind, I was triggering it right. It turns out it was a QDockWidget event and not a QMainWindow event that I needed to trigger though. For anyone who comes up with a similar problem in the future I solved it by putting this in my reimplemented dropEvent function after I reparented the QDockWidget:

    Qt Code:
    1. QEvent reParentEvent1(QEvent::MouseMove); // Mouse move (QMouseEvent) - 5
    2. QApplication::sendEvent(child, &reParentEvent1);
    To copy to clipboard, switch view to plain text mode 

    That allowed the dock widget to immediately go to letting the user place its new child widget in the dock.

    Thanks for the help!
    Last edited by TEAmerc; 1st October 2015 at 20:12.

Similar Threads

  1. Replies: 2
    Last Post: 30th January 2013, 06:02
  2. action triggered no emit
    By waiter in forum Newbie
    Replies: 3
    Last Post: 28th September 2012, 00:26
  3. find out which shortcut triggered action
    By qt_gotcha in forum Newbie
    Replies: 3
    Last Post: 23rd August 2010, 21:27
  4. Replies: 1
    Last Post: 12th June 2010, 10:17
  5. Capture the triggered event of MacWindowToolBarButtonHint
    By alexandersv in forum Qt Programming
    Replies: 0
    Last Post: 11th October 2009, 18:05

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.