Question

I need to know if there is a way to close an opened QMenuBarItem in Qt. I mean, if I Open a Menu, I want a QTimer to be able to close the QMenuBar after some time.

I am starting a QTimer when I click a menu (like "File"), and in the QTimer's timeout() slot I am using the next code:

menubar->actions()[0]->menu()->close();

Where menubar->actions()[0] is the "File" menu.

I have been searching without success and I really need to close the menu automatically.

I really appreciate your help and your time. Thanks in advance.

*****EDIT

You must use menubar.setActiveAction(NULL);

Was it helpful?

Solution

Try QWidget::hide() instead of QWidget::close().

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top