self.sender() always None

  • I'm using PySide. I have a QTableWidget with QComboBoxes inside, which was done by using setCellWidget. I connect each combo box's currentIndexChanged signal to a slot. When I try to get the combo box that sent the signal using self.sender(), it's always None. Does anyone else have this problem?

  • Lifetime Qt Champion


    Can you show a minimal sample code that exhibit this behavior ?

  • What's weird is I tried the same code again today, but I'm getting the sender this time. Something is not right with how PySide passes the sender, but I can tell this is one of those bugs that will be really hard to track down since it's really inconsistent. Here's a simplified version of what I'm working with:

    import sys
    from PySide.QtCore import *
    from PySide.QtGui import *
    class CustomDialog(QDialog):
        def __init__(self, parent=None):
            super(CustomDialog, self).__init__(parent)
            self.table = QTableWidget()
            for row in xrange(self.table.rowCount()):
                item = QTableWidgetItem(str(row))
                self.table.setItem(row, 0, item)
                combo = QComboBox()
                combo.addItems(['one', 'two', 'three'])
                self.table.setCellWidget(row, 1, combo)
        def onIndexChanged(self, index):
            print self.sender()
    def main():
        app = QApplication(sys.argv)
        dialog = CustomDialog()
    if __name__ == '__main__':

    If you don't get the bug, I wouldn't spend too much time looking into it, but I appreciate the help.

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.