globalPos()); 我如何控制-6ren">
gpt4 book ai didi

c++ - Qt中的弹出菜单事件控件

转载 作者:行者123 更新时间:2023-11-28 07:26:57 26 4
gpt4 key购买 nike

当我在Qt中添加弹出菜单如下:

QMenu menu(widget);
menu.addAction("AAA");
menu.exec(eventPress->globalPos());

我如何控制“AAA” Action 事件。例如单击“AAA” 时执行某些操作。

最佳答案

您可以重载 addAction。

From Qt assistant
This convenience function creates a new action with the text text and an optional shortcut shortcut. The action's triggered() signal is connected to the receiver's member slot. The function adds the newly created action to the menu's list of actions and returns it.

MyClass::Popup()
{
QMenu menu(widget);
menu.addAction("AAA", this, SLOT(burnCase()));
menu.exec(eventPress->globalPos());
}

// This is your slot
MyClass::burnCase()
{

}

关于c++ - Qt中的弹出菜单事件控件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18598469/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com