I manually added the following menu to my QTableWidget.
Here is what I have:
context-menu.png
Part of the code was setup using Qt Designer and I'm modifying it slightly in my code.
Here is the code that I've added to have a context menu:
self.group1RegistersTableWidget.addAction(self.act ionReadRegister)
self.group1RegistersTableWidget.addAction(self.act ionWriteRegister)
self.actionSeparator.setSeparator(True)
self.actionSeparator.setText("")
self.group1RegistersTableWidget.addAction(self.act ionSeparator)
self.group1RegistersTableWidget.addAction(self.act ionBinRegisterFormat)
self.group1RegistersTableWidget.addAction(self.act ionDecRegisterFormat)
self.group1RegistersTableWidget.addAction(self.act ionHexRegisterFormat)
self.group2RegistersTableWidget.addAction(self.act ionReadRegister)
self.group2RegistersTableWidget.addAction(self.act ionWriteRegister)
and here is the code that I used
I'm somewhat new to Qt. How do I process these actions. How do I know that Read/Write/Binary/Decimal/Hexadecimal has been clicked. As far as I understand I need to connect some signal to some slot, but I can't figure out which ones. Would someone be able to help me out. I'm using `PyQt4`, but C++ code would also be fine.
Any help is appreciated.
Bookmarks