qaction不显示_QAction无法连接到我的插槽

I'm trying to make an IHM with Qt, and I started by making a basic menu (File,Edit...).

So far, I have my menu containing "File", which then display "New Project, Open Project, Exit".

Look great, but my problem is I can't seem to trigger these Action (clicking them or by key shortcut).

Here is my slot:

void KoriganEngine::launchNewProjectWidget(){

//External QWidget

m_nwProj = new NewProjectWidget(NULL,Qt::MSWindowsFixedSizeDialogHint);

m_nwProj->show();

}

If I use this slot with a pushbutton connected, my new QWidget is displayed properly.

However, impossible to do the same thing with an action...

Here is the code of my actions and menu:

void KoriganEngine::KG_createMenus(){

//init actions

KG_createMenuActions();

//add menu to the bar

m_fileMenu = menuBar()->addMenu("File");

m_fileMenu->addAction(m_newProjAction);

m_fileMenu->addAction(m_openProjAction);

m_fileMenu->addSeparator();

m_fileMenu->addAction(m_quitAction);

m_editMenu = menuBar()->addMenu("Edit");

}

void KoriganEngine::KG_createMenuActions(){

m_newProjAction = new QAction("New Project...", this);

m_newProjAction->setShortcuts(QKeySequence::New);

m_newProjAction->setStatusTip(QString("Create a new Project"));

connect(m_newProjAction, SIGNAL(trigerred()), this, SLOT(slottest()));

m_openProjAction = new QAction("Open Project...", this);

m_openProjAction->setShortcuts(QKeySequence::Open);

m_openProjAction->activate( QAction::Hover);

connect(m_openProjAction, SIGNAL(trigerred()), this, SLOT(launchNewProjectWidget())); //TODO replace the slots

m_quitAction = new QAction("Exit", this);

connect(m_quitAction, SIGNAL(trigerred()), this, SLOT(quit()));

}

And the code that works with a button:

connect(m_button, SIGNAL(clicked()), this, SLOT(launchNewProjectWidget()));

So I don't really get why it should not react the same, I've read the Qt examples over and over... I must have missed something, but if anyone as an idea, I'll be more than grateful, as it's starting to make me hate life :p

Thank you all.

PS: Ok, not sure I handle great the code blocks buisness, in my defence it's really weird to use... :p

解决方案

You made a mistake in triggered word :P It should be:

connect(m_quitAction, SIGNAL(triggered()), this, SLOT(quit()));

------

Triggered, not trigerred! :)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值