<html>
  <head>

    <meta http-equiv="content-type" content="text/html; charset=utf-8">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <p><br>
    </p>
    <div class="moz-forward-container"><br>
      <br>
      -------- Weitergeleitete Nachricht --------
      <table class="moz-email-headers-table" border="0" cellspacing="0"
        cellpadding="0">
        <tbody>
          <tr>
            <th nowrap="nowrap" valign="BASELINE" align="RIGHT">Betreff:
            </th>
            <td>Re: [Eric] PyQt-Slot for QtWidget (QComboBox) created
              during runtime</td>
          </tr>
          <tr>
            <th nowrap="nowrap" valign="BASELINE" align="RIGHT">Datum: </th>
            <td>Sun, 23 Sep 2018 23:30:33 +0200</td>
          </tr>
          <tr>
            <th nowrap="nowrap" valign="BASELINE" align="RIGHT">Von: </th>
            <td>GM <a class="moz-txt-link-rfc2396E" href="mailto:mossl@gmx.net"><mossl@gmx.net></a></td>
          </tr>
          <tr>
            <th nowrap="nowrap" valign="BASELINE" align="RIGHT">An: </th>
            <td>Christos Sevastiadis <a class="moz-txt-link-rfc2396E" href="mailto:csevast@auth.gr"><csevast@auth.gr></a></td>
          </tr>
        </tbody>
      </table>
      <br>
      <br>
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
      <p>Christos,</p>
      <p>thanks ... works in the same way and there's no need for an own
        class, I just have a problem with the rownumber.</p>
      <p>If users add more than one line, there will exist 2 or more
        Comboboxes. Each of them will return the right index, but so far
        I could not find a way to get the right row, because the
        self.tableWidgetX.currentRow() returns the last row where a
        text-cell was entered. This means row is -1 when nobody clicked
        somewhere on the grid, and if you enter row 2, and then change
        the combobox in row 5, self.tableWidgetX.currentRow() will
        return 2!</p>
      <p>As the row-number in Serges solution is passed plain this is
        also not a 100% solution as the row-sorting could be changed
        (user sorts data by clicking on headers, or rows are
        (re)moved/added by code). But if I prevent this at last the
        row-number should be correct.<br>
      </p>
      For short, the way I've tested your solution:<br>
      <br>
          from PyQt5.QtWidgets import QComboBox<br>
      <br>
          @pyqtSlot()<br>
          def on_pushButton_add_row_to_tableWidgetX_clicked(self):<br>
                  tWid=getattr(self, "tableWidgetX")<br>
                  tWid.setRowCount(tWid.rowCount()+1)<br>
                  combo = QComboBox()<br>
                  combo.setSizeAdjustPolicy(QComboBox.AdjustToContents)<br>
                  combo.addItems(["A","B","C"])<br>
                  tWid.setCellWidget(tWid.rowCount()-1, 3, combo) #
      ComboBox goes to last row, column Nr 3<br>
                  tWid.setColumnWidth(3, combo.size().width())<br>
                 
combo.currentIndexChanged.connect(self.on_spk_ver_rep_QComboBox_currentIndexChanged)<br>
      <br>
          @pyqtSlot(int)<br>
          def on_spk_ver_rep_QComboBox_currentIndexChanged(self, index):<br>
              print(index,  self.tableWidgetX.currentRow())<br>
      <br>
      george<br>
      <br>
      <div class="moz-cite-prefix">Am 23.09.2018 um 19:11 schrieb
        Christos Sevastiadis:<br>
      </div>
      <blockquote type="cite"
cite="mid:CADvHiAzRq5J+wFmwjVSjPJsi7DGELGva_SRDwkm+FNziFwsxjg@mail.gmail.com">
        <div dir="ltr">
          <div dir="ltr">
            <div>Dear George,</div>
            <div><br>
            </div>
            <div>I think that you should create a slot for the specific
              QComboBox object and not for the cell of the QTableWidget
              object.</div>
            <div>For example, for a QComboBox created in the <span>Ui_MainWindow.setupUI()</span>,
              the corresponding slot created in the <span>MainWindow.setupUI()</span>
              should have the following form, for integer or string type
              index.</div>
            <div><br>
            </div>
            <div><span>    @pyqtSlot(int)<br>
                    def
                on_spk_ver_rep_QComboBox_currentIndexChanged(self,
                index):<br>
                        """<br>
                        Slot documentation goes here.<br>
                        <br>
                        @param index DESCRIPTION<br>
                        @type int<br>
                        """<br>
                        # TODO: not implemented yet<br>
                        raise NotImplementedError<br>
                    <br>
                    @pyqtSlot(str)<br>
                    def
                on_spk_ver_rep_QComboBox_currentIndexChanged(self, p0):<br>
                        """<br>
                        Slot documentation goes here.<br>
                        <br>
                        @param p0 DESCRIPTION<br>
                        @type str<br>
                        """<br>
                        # TODO: not implemented yet<br>
                        raise NotImplementedError<br>
              </span></div>
          </div>
          <div dir="ltr"><br>
          </div>
          <div>Christos<br>
          </div>
          <div><br>
          </div>
          <div><br>
          </div>
          <div><br>
          </div>
          <div class="gmail_quote">
            <div dir="ltr">On Sun, 23 Sep 2018 at 15:40, GM <<a
                href="mailto:mossl@gmx.net" moz-do-not-send="true">mossl@gmx.net</a>>
              wrote:<br>
            </div>
            <blockquote class="gmail_quote">Hi @all,<br>
              <br>
              I've created a dialog-window with an QTableWidget. Users
              can add a row <br>
              by using a pushbutton. In a cell of the new row appears a
              QComboBox. How <br>
              can changes of this QComboBox trigger a function?<br>
              <br>
              It's no problem for to text-only-cells (I can use:<br>
              <br>
                   @pyqtSlot(int, int)<br>
                   def on_tableWidgetX_cellChanged(self, row, column):<br>
                       print("cell changed: ", row, column)<br>
              <br>
              which works as intended.)<br>
              <br>
              Functions like<br>
              <br>
                   @pyqtSlot(QComboBox)<br>
                   def on_tableWidgetX_itemChanged(self, item):<br>
                       print("OK1")<br>
              <br>
                   @pyqtSlot(QComboBox)<br>
                   def on_tableWidgetX_itemClicked(self, item):<br>
                       print("Ok2")<br>
              <br>
              never recieve a signal.<br>
              <br>
              I think the QComboBox can not send a aignal. Originally
              the "Generate <br>
              Dialog Code..."-dialog suggests to pass a
              "QTableWidgetItem*" to the <br>
              pyqtSlot, but this Item is created during runtime, so it
              can not be <br>
              found in the Ui_Dialog...<br>
              <br>
              Any suggestions?<br>
              <br>
              <br>
              george<br>
              <br>
              _______________________________________________<br>
              Eric mailing list<br>
              <a href="mailto:Eric@riverbankcomputing.com"
                target="_blank" moz-do-not-send="true">Eric@riverbankcomputing.com</a><br>
              <a
                href="https://www.riverbankcomputing.com/mailman/listinfo/eric"
                rel="noreferrer" target="_blank" moz-do-not-send="true">https://www.riverbankcomputing.com/mailman/listinfo/eric</a><br>
            </blockquote>
          </div>
        </div>
      </blockquote>
      <br>
      <pre class="moz-signature" cols="72">-- 
Georg Mößlacher
+43-664-735 69 327</pre>
    </div>
  </body>
</html>