PyQt4 - can't receive sender() signal / how to indentify which button is clicked and match it with the appropriate progressbar?

前端 未结 1 1905
生来不讨喜
生来不讨喜 2021-01-18 13:01

Why i can\'t receive self.sender() output? My point is to identify which button is clicked (to start a download function) and then match the corresponding progress bar for a

相关标签:
1条回答
  • 2021-01-18 13:34
    def buttonClicked(self):
        buttonHandle = self.sender()
        print buttonHandle
    

    self here would be the Ui_MainWindow which is not a QT object, you probably want to check .sender of MainWindow. so set a class variable of UI_MainWindow to the MainWindow object and check sender of that object.

    def setupUi(self, MainWindow):
        self.MainWindow = MainWindow
        ....
    
    def buttonClicked(self):
        buttonHandle = self.MainWindow.sender()
        print buttonHandle
    
    0 讨论(0)
提交回复
热议问题