Important: Please read the Qt Code of Conduct -

How to ignore click that closes/hides the contextual menu ?

  • Hello,

    I am facing a problem where an event is processed when I left click to exit from the contextual menu.

    1. Right click -> Contextual menu appears
    2. Left click anywhere but on any contextual action -> the contextual menu disappears as expected
    3. That left click is processed as a standard left click and initiate some stuff I don't want, I just wanted to exit from contextual menu.

    How can I prevent from that ?

    Thank you!

  • Lifetime Qt Champion

    Hi and welcome to devnet,

    What does happen ?
    On what kind of widget does it happen ?
    What OS ?
    What Qt version ?

  • Win7, Qt 5.9.1

    It is a QWidget that handle a plotter paint area where we draw curves.
    The left click starts to edit the curve as a normal left click would do but that particular left click was just supposed to close/hide the contextual menu and nothing more.

  • Lifetime Qt Champion


    So the issue is that clicking outside the context popup menu does close the menu but ALSO triggers
    an action just as if user clicked directly on it ?

    Please make a small default GUI project and try it there so we are sure its not
    something in your code that does it. :)

Log in to reply