Unsolved same actions to execute different slots
-
Since you build up the context menu it should be possible to store this information in your action handler.
-
@christian-ehrlicher
that's almost what i mean. when building up the context menu, i should be setting the bool value? -
Sorry, I misread the last sentence from you. This is something similar to what I would do. But on the other hand - since you need to do different things inside the actions for the table and the tree I would maybe add this specific part inside the tree/table view derived class and the common stuff somewhere else.
-
The common way is to look at the sender object in your slot method:
if(sender() == myTable) do ... else if(sender() == myTree) do ... etc ...
-
@christian-ehrlicher
actually it's not different things, it's the same thing (e.g. update), only applied to different number of items.
table view applies to only selected rows, and tree views applies to all items.
so in case of tree view i need to tell the action handler to update ALL items.@mpergand
yeah right. if i don't find a more elegant solution, i'll use that. -
@mpergand said in same actions to execute different slots:
The common way is to look at the sender object in your slot method:
The problem is that the sender here is the QAction and/or QMenu...
-
@user4592357 said in same actions to execute different slots:
actually it's not different things, it's the same thing (e.g. update), only applied to different number of items.
So why do you need to distinguish then at all?
-
@christian-ehrlicher
to pass the correct parameters - the numbers of selected rows, or * (to indicate all items) -
Then do what I said above - implement the different logic inside the view, then call a function which does the common stuff.
-
@christian-ehrlicher
i'm thinking of another solution, have a method inactionHandler
to take the rows to be updated. the table will set the selected rows numbers, and the tree will set*
. that way processing will be done the actions handler now.