0

The component being connected is a combobox within a table. The connection works, but I want to be able to pass arguments to the function. Just as a simplified example, I made those arguments the cell row and column, as well as a password.

def setTableCellToCombo(qtbl, row, column, password): #qtbl is a QTableWidget
    qtbl.blockSignals(True)
    comp = QtWidgets.QComboBox()
    comp.insertItems(0, ['Example'])
    comp.setCurrentIndex(0)
    qtbl.setCellWidget(row, column, comp)
    comp.currentIndexChanged.connect(comboListener(row, column, password))
    qtbl.blockSignals(False)

def comboListener(row, column, password):
    print(password)

The error I get is: TypeError: Qt.ConnectionType expected, not 'function'

Is there a way to pass arguments to the connected 'comboListener' function? And if so, how?

Zhiming010
  • 303
  • 4
  • 14
  • In your case: `comp.currentIndexChanged.connect(lambda ix, r=row, c=column, p= password: comboListener(r, c, p))` – eyllanesc Jan 01 '18 at 07:48
  • Glad you left this comment -- I originally tried doing it as 'lambda: comboListener(row, column, password)' directly and was getting the same column and row every time. With your adjustment I fixed that issue; thanks! – Zhiming010 Jan 01 '18 at 07:53

0 Answers0