<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html>
<head>
  <meta name="Generator" content="Zarafa WebAccess v7.0.15-42709">
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  <title>trigger on_item_changed when currentIndexChanged on combobox in qtablewidget</title>
  <style type="text/css">
      body
      {
        font-family: Arial, Verdana, Sans-Serif ! important;
        font-size: 12px;
        padding: 5px 5px 5px 5px;
        margin: 0px;
        border-style: none;
        background-color: #ffffff;
      }

      p, ul, li
      {
        margin-top: 0px;
        margin-bottom: 0px;
      }
  </style>
</head>
<body>
<p>Hi list,</p><p> </p><p>environment pyqt5, linu</p><p> </p><p>We designed a editable qtablewidget with a combobox in one of the cell. Everything works as planned, except for the combobox. When an item is selected in the combobox, this should trigger a function so that the changes can be stored. For the other columns this works OK, however the "on_item_changed" is method is NOT triggered when one changes the combobox. My code is as follows:</p><p> </p><p>class timePointWidget(QTableWidget):</p><p> </p><p>    def __init__(self, parent, protocol, operation):</p><p>        super(timePointWidget, self).__init__(parent)</p><p>self.itemChanged.connect(self.on_item_changed)</p><p> </p><p>    def on_item_changed(self, item):</p><p> print(item.row())</p><p> </p><p>    def populate(self):</p><p>        self.timepoints_underconstruction = [t for t in self.protocol.timepoints]</p><p>        for row, tp in enumerate(self.timepoints_underconstruction):</p><p>            value, unit = self.showtimepoint(tp)</p><p>            self._populate_row(row, (tp.timepoint_description, tp.timepoint_repeat, value), unit )</p><p> </p><p>        if not self.operation == 'Delete':</p><p>            self.input_row(row+1)</p><p>        self.resizeColumnsToContents()</p><p> </p><p>    def input_row(self, row):</p><p>        self._populate_row(row, (_('Add timepoint'), '', ''), _('min'))</p><p>        self.setRowCount(row+1)</p><p> </p><p>    def _populate_row(self, row, columns, combobox_value):</p><p>        self.insertRow(row)</p><p>        for col_idx, col in enumerate(columns):</p><p>            item = QTableWidgetItem(str(col))</p><p>            item.setText(str(col))</p><p>            self.setItem(row, col_idx, item)</p><p>        combo = QComboBox()</p><p>        sig_mapper = QSignalMapper()</p><p>        sig_mapper.mapped.connect(self.on_item_changed)</p><p>        combo.currentTextChanged.connect(sig_mapper.map)</p><p>        self.setCellWidget(row, 3, combo)</p><p>        sig_mapper.setMapping(combo, combo)</p><p>        [combo.addItem(unit) for unit, trans, factor in self.units]</p><p>        combo.setCurrentText(combobox_value)</p><p> </p>
</body>
</html>