Results 1 to 1 of 1

Thread: How to prevent "What's this?" on right click

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,315
    Thanks
    314
    Thanked 870 Times in 857 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default How to prevent "What's this?" on right click

    I have implemented a custom state machine for handling mouse and keyboard interactions with a graphical plot. The state machine is attached to a QGraphicsView and installs an event filter on the view to intercept mouse, keyboard, and wheel events. I recently ported this to Qt 5, and now I am observing different behavior during right mouse clicks.

    In Qt 4.8, I could turn off context menus when I wanted to turn on right mouse click handling in my state machine, and this prevented both the context menus and the "What's this?" box from appearing. In Qt 5, the "What's this?" box appears all the time. It also seems to interfere with the event filter in the state machine, but this is very hard to debug because, of course, if a breakpoint is set, clicking the mouse immediately transfers to the debugger and messes things up in the state machine.

    I added a case to handle QEvent::WhatsThis event types in my event filter, but this condition is never hit, so apparently the event never makes it that far. If I return "true" from the event filter for the mouse button press event, call accept(), or call ignore() on the mouse event, the "what's this?" box still appears.

    The graphics view widget is embedded as a child widget in a popup dialog. This dialog does have a "What's this" string defined, and it is this text that is displayed when I double-click the "What's this?" box. So the event seems to be triggered somewhere way up the chain of command, not at the level of my graphics view widget.

    Given that my graphics view widget is a reusable component that has no idea about where it is being used, and that the popup dialog doesn't have any idea about the workings of the graphics view widget, how can I disable the "What's this?" behavior of the popup dialog from inside my state machine? I still want it to work when the mouse is outside my widget, so turning it off in the dialog itself is not an option.

    Any ideas?

    -------
    Later: After a bit more research, I have found that if I set the widget attribute Qt::WA_CustomWhatsThis on the widget that uses the state machine, the QEvent::WhatsThis now gets passed to the event filter in the state machine. Unfortunately, it hits after the "What's this?" box is displayed in the graphics view, so I cam still no closer to a solution. I also added a case for QEvent::QueryWhatsThis, but that isn't passed in even with the custom whats this flag set.

    So, still looking for ideas.

    -------
    Still later: OK, if I call setContextMenuPolicy( Qt:: PreventContextMenu ) or setWhatsThis( "" ) in the popup dialog constructor then the right mouse press works as desired. But then I have no "What's this" help on the popup dialog. So it doesn't seem as though there is a way to implement "What's this" behavior for a parent widget while disabling it for a child contained within that parent.

    And I'm still looking for ideas...
    Last edited by d_stranz; 26th November 2013 at 00:56.

Similar Threads

  1. Replies: 2
    Last Post: 20th June 2013, 09:19
  2. QWebView "Adobe Flash Player Settings" can't click
    By MLangley in forum Qt Programming
    Replies: 2
    Last Post: 9th December 2011, 23:10
  3. "Change widget class on button click" problem
    By utkozanenje in forum Newbie
    Replies: 3
    Last Post: 23rd May 2011, 00:40
  4. Replies: 1
    Last Post: 3rd May 2010, 09:25
  5. Translation QFileDialog standart buttons ("Open"/"Save"/"Cancel")
    By victor.yacovlev in forum Qt Programming
    Replies: 4
    Last Post: 24th January 2008, 19: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
  •  
Qt is a trademark of The Qt Company.