答案 0 :(得分:1)
可以通过重载QLineEdit小部件的contextMenuEvent来调整上下文菜单中的操作。
修改:
上面链接的代码:
void LineEdit::contextMenuEvent(QContextMenuEvent *event)
{
QMenu *menu = createStandardContextMenu();
menu->addAction(tr("My Menu Item"));
//...
menu->exec(event->globalPos());
delete menu;
}
我实际用于我目的的代码:
menu = self.createStandardContextMenu()
menu.actions()[5].connect(self.paste) # The hard ref to the 6th item is not ideal but what can you do...
menu.exec_(event.globalPos())