I have created a right-click menu function where all the right-click functions are linked to a QAction
Eg:
self.contextMenu = QtWidgets.QMenu(self)
self.contextMenu.addAction(self.actionAdd_Data)
self.pushButton.customContextMenuRequested.connect(self.initContextMenu)
def initContextMenu(self, event):
action = self.contextMenu.exec_(self.pushButton.mapToGlobal(event))
if action == self.actionAdd_Data:
print("Do something")
Is it possible that I can emulate clicking on the right-click button? Something like pushButton.click() but for the QAction instead.
I have tried
self.pushButton2.clicked.connect(self.actionAdd_Data.trigger)
But nothing happens.
Can anyone help? Thanks.