开发者

Hiding an entry from a QMenuBar in Qt4?

开发者 https://www.devze.com 2022-12-25 00:29 出处:网络
I can find no non-deprecated way of hiding an item in a m开发者_运维知识库enu bar in Qt4. This post: http://qt.nokia.com/developer/faqs/585 gives a method that uses deprecated Qt3 compatibility funct

I can find no non-deprecated way of hiding an item in a m开发者_运维知识库enu bar in Qt4.

This post: http://qt.nokia.com/developer/faqs/585 gives a method that uses deprecated Qt3 compatibility functions.

Is there a better way?


QAction::setVisible() is what you are looking for:

QAction* act = new QAction(tr("&Moo"), this);
someMenu->addAction(act);

// ...

act->setVisible(false);

To apply that to menus use their QAction* which you get either via QMenu::menuAction() or from QMenu::addMenu() (depending on what overload you use).

0

精彩评论

暂无评论...
验证码 换一张
取 消