• 3899阅读
  • 1回复

[提问]Action的setShortCut有的有效,有的无效 [复制链接]

上一主题 下一主题
离线zhurenxi
 
只看楼主 倒序阅读 楼主  发表于: 2013-02-05
关键词: QAction


代码如下

void Window::setupAction(){
    newAction = new QAction(tr("&New"), this);
    newAction->setIcon(QIcon(":/images/new.png"));
    newAction->setShortcut(QKeySequence(tr("Ctrl+N")));
    newAction->setStatusTip(tr("Create a new spreadsheet file"));
    QObject::connect(newAction, SIGNAL(triggered()), this, SLOT(newFile()));

    dbTreeShowHideAction=new QAction(tr("&dbTreeShowHide"),this);
    dbTreeShowHideAction->setShortcut(QKeySequence(tr("Ctrl+M")));
    QObject::connect(dbTreeShowHideAction,SIGNAL(triggered()),this,SLOT(showHideDBTree()));
}

newAction的shortcut其效果,但是dbTreeShowHideAction的SetShortCut却是无效的,求帮助!求帮助
谢谢大家了!
离线zhurenxi
只看该作者 1楼 发表于: 2013-02-05
晕...无效的Action没放到QMenu里...QAction一定要放到QMemu里才有效吗?
快速回复
限100 字节
 
上一个 下一个