qt4 - QT: Context menu (QMenu) reference from the QTableWidget -
I want to add a submenu in my context menu that is created like this:
Self.widget_alignment.setContextMenuPolicy (Qt.ActionsContextMenu)
where widget_alignment is QTableWidget .
I have created a new QMenu example:
exchange_bases_menu = QMenu (self.widget_alignment)
has added some actions , And I found a method
but I did not find any reference on the default reference menu for self.widget_alignment Additionally, this code:
self.widget_alignment.addMenu ( Exchange_bases_menu)
gave me: There is no attribute addMenu in the QTableWidget object.
How do I add my submenu to the default context menu?
According to the document, when setting a QWidget
action context menu type , The widget will create a context menu based on the list of tasks assigned to the widget. To modify the list of tasks, you can call addAction
, insertAction
, or removeAction
. So I hope you can do something like this (in C ++):
QAction * act_p = new queue ("submenu", widget_imainment); QWenu * Submenu_p = New QMenu (ACT_PP); // add item to submenu act_p-> Set menu (submenu_p); Widget_alignment-> Addiction (act_p);
Without trying it on my own, I hope that with the submenu created as a user, add "Has Submenu" option below the context menu generated for the widget. Will be shown.
Comments
Post a Comment