Close QMenuBar item automatically

332 views Asked by At

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);

1

There are 1 answers

0
Anthony On BEST ANSWER

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