Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

How to get value of a particular cell in QTableWidget on double clicking?



  • I am trying to get the value of a particular cell and store it in a variable, on double clicking a cell (itemdoubleclicked event) in QTableWidget. I know that it should be done by itemdoubleclicked event handler, but not sure how to get value of that cell. It should be something like below:

    self.ui.tableWidget.itemDoubleClicked.values()

    But, this shows an error:

    AttributeError: 'PyQt5.QtCore.pyqtBoundSignal' object has no attribute 'values'

    So, values is not an attribute for itemDoubleClicked. Could you please help with the correct way to get the value of particular cell?


  • Lifetime Qt Champion

    @Piyush Check the documentation http://doc.qt.io/qt-5/qtablewidget.html#itemDoubleClicked
    You get the double clicked item as signal/slot parameter:

    void QTableWidget::itemDoubleClicked(QTableWidgetItem *item)
    

    This does not make any sense:

    self.ui.tableWidget.itemDoubleClicked.values()
    

    You should have your slot connected to this signal:

    def onItemDoubleClicked(self, item):
        pass
    

Log in to reply