我在QMenu中加入了一个QAction类型的findAction,连接信号与槽,如下
connect(findAction,SIGNAL(triggered()),this,SLOT(emerge()));
槽函数如下
void demo::emerge()
{
int a = qApp->mouseButtons();
if(qApp->mouseButtons() == Qt::LeftButton)
{
QMenu* saveMenu = new QMenu(tr("save"));
exitAction = new QAction(tr("save"),0);
saveMenu->addAction(exitAction);
menuBar->addMenu(saveMenu);
}
}
我右键单击findAction,运行发现其中的a=0,也就是说返回的是noButton;换成左键单击也一样的结果。不知道大家有没有碰到过这种问题,怎样解决的?急啊!!!