PyQt sending parameter to slot when connecting to a signal

前端 未结 5 1299
青春惊慌失措
青春惊慌失措 2020-12-02 18:37

I have a taskbar menu that when clicked is connected to a slot that gets the trigger event. Now the problem is that I want to know which menu item was clicked, but I don\'t

5条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-02 19:15

    I'd also like to add that you can use the sender method if you just need to find out what widget sent the signal. For example:

    def menuClickedFunc(self):
        # The sender object:
        sender = self.sender()
        # The sender object's name:
        senderName = sender.objectName()
        print senderName
    

提交回复
热议问题