QWidgetAction : how to make the menu disappear after the user completes his input

StackOverflow https://stackoverflow.com/questions/5319179

  •  24-10-2019
  •  | 
  •  

سؤال

In my QMenuBar, I have several menus.

One of those menus has a QWidgetAction in it.

It shows up fine, but the problem is that once the user completes his input, I want the menu to disappear (as is the normal behavior for a classical QAction).

However, I am not sure on how to do that. In my QWidgetAction, there is a button the user presses when he is done; I can therefore bind to this button's clicked() signal.

In the slot, I tried to setFocus() an element outside the menu but the menu still doesn't disappear.

How to tell the menu to close itself when my users finish interacting with the QWidgetAction?

Thanks

هل كانت مفيدة؟

المحلول

QMenu inherits QWidget, so calling yourMenu->hide() should do the work.

Hope this helps.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top