• 7230阅读
  • 4回复

【提问】菜单隐藏后,还能响应快捷键吗? [复制链接]

上一主题 下一主题
离线keios
 

只看楼主 倒序阅读 楼主  发表于: 2006-03-04
我在 QMainWindow 中加了菜单,并对其中的某些 action 加了快捷键 (setShortcut),

menuBar()->setVisible(false) ;
把菜单隐藏,之后快捷键就不起作用了。
请问是我用错了,还是本身 QT 就是这样?(我用的是qt v4.1)
如果希望实现这样的功能,通常使用什么方法?
先谢了
离线XChinux

只看该作者 1楼 发表于: 2006-03-04
这是QAction中的内容:

shortcutContext : Qt::ShortcutContext
This property holds the context for the action's shortcut.
Valid values for this property can be found in Qt::ShortcutContext. The default value is Qt::WindowShortcut.
Access functions:
Qt::ShortcutContext shortcutContext () const
void setShortcutContext ( Qt::ShortcutContext context )
enum Qt::ShortcutContext
For a QEvent::Shortcut event to occur, the shortcut's key sequence must be entered by the user in a context where the shortcut is active. The possible contexts are these:
Constant
Value
Description
Qt::WidgetShortcut
0
The shortcut is only triggered when its parent widget has focus.
Qt::WindowShortcut
1
The shortcut is triggered when its parent widget is a logical subwidget of the active top-level window.
Qt::ApplicationShortcut
2
The shortcut is triggered when the application is active.
二笔 openSUSE Vim N9 BB10 XChinux@163.com 网易博客 腾讯微博
承接C++/Qt、Qt UI界面、PHP及预算报销系统开发业务
离线keios

只看该作者 2楼 发表于: 2006-03-06
我把所有的快捷键都设置成WindowShortcut或者ApplicationShortcut,
结果还是一样,隐藏之后就不响应了
离线keios

只看该作者 3楼 发表于: 2006-03-07
高手请出招,给我一个答案,谢谢!
离线wxg0130

只看该作者 4楼 发表于: 2009-03-30
同样的问题啊
    a = new QAction( QPixmap( ), TFrameForm::tr( "Full Screen" ), qApp->mainWidget() );
    a->setShortcut( Qt::Key_F8 );
    a->setShortcutContext(Qt::ApplicationShortcut);
隐藏之后就再也不响应快捷键了,楼主解决了吗?谢谢回答啊
Everything is Nothing
快速回复
限100 字节
 
上一个 下一个