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?


  • Moderators

    @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
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.