Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Language Bindings
  4. self.sender() always None
Forum Update on Monday, May 27th 2025

self.sender() always None

Scheduled Pinned Locked Moved Language Bindings
signalslot
3 Posts 2 Posters 3.2k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    elveatles
    wrote on last edited by elveatles
    #1

    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?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

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

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • E Offline
        E Offline
        elveatles
        wrote on last edited by elveatles
        #3

        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.setLayout(QVBoxLayout())
        
                self.table = QTableWidget()
                self.table.setColumnCount(2)
                self.layout().addWidget(self.table)
        
                self.table.setRowCount(10)
                for row in xrange(self.table.rowCount()):
                    item = QTableWidgetItem(str(row))
                    self.table.setItem(row, 0, item)
        
                    combo = QComboBox()
                    combo.addItems(['one', 'two', 'three'])
                    combo.currentIndexChanged.connect(self.onIndexChanged)
                    self.table.setCellWidget(row, 1, combo)
        
            @Slot(int)
            def onIndexChanged(self, index):
                print self.sender()
        
        def main():
            app = QApplication(sys.argv)
            dialog = CustomDialog()
            dialog.show()
            app.exec_()
        
        if __name__ == '__main__':
            main()
        

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

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved