Wednesday 15 July 2015

c++ - QTableWidget - QMenu Context Menu - AddAction slots not calling functions -


I am trying to call a function via the embedded context menu inside QTablewidget, call the function in this slot does not do. Am I missing something? Clicking on the context menu appears does nothing.

  QMenu * contextMenu = new QMenu; QModelIndex cell = ui- & gt; Table Widget-> IndexAut (Pause); If (cell.isValid ()) {contextMenu- & gt; AddAction ("burn case", this, slot (burnaccase ())); ContextMenu- & gt; Addition ("export case", this, slot (export (cell.row ())); ContextMenu- & gt; Addition ("Remove Case", This Slot (Delcace (Cell.ro ())); ContextMenu- & gt; Executive (UI-> TableWidget-> MapToGlobal (POS)); }   Update:   

The slot works without any parameters being passed, but not the parameters

slot (exportCase (cell.row ())) is not valid The connection string must be included in the SLOT () macro the name of the slot and its logic type. You can not pass the logic value directly, so if your slot accepts int , then the statement will be slot (exportCase (int)) .

In addition, you can not add a signal to a slot with any discrepancy. QMenu :: addAction connects your slot to the QAction :: triggered (bool) sign, so you must have an argument with a single bool argument Only slots can be used with slots.

Return value of a run-time connect connect () If you have any problems then you will better check it. In addition, the autocomplete of Qt Creator can help you use SIGNAL () and SLOT () macros.

Also see.

No comments:

Post a Comment