Pergunta

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

Foi útil?

Solução

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

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top