Important: Please read the Qt Code of Conduct -

[SOLVED]QTableWidgetItem, detect when it is changed

  • Hi!

    I have a class which inhertis_QTableWidget_. I'd like to detect all changes made to it's QTableWidgetItems. I've looked through docs, but I did not find any method that does that. Only thing I found are signals with which I can track current selected cell.
    Can this be done with QTableWidget or will I have to either use models or inherit from QTableWidgetItem and write my own signals? ( But again, I haven't found any method that QTableWidgetItem has, to provide detection whenever it was changed).

    Thanks in advance.


  • Hi Jake,
    You are correct, the signals are very useful in detecting any kind of change to your QTableWidget. Signals not only track current selected cell but following -

    void cellActivated ( int row, int column )
    void cellChanged ( int row, int column )
    void cellClicked ( int row, int column )
    void cellDoubleClicked ( int row, int column )
    void cellEntered ( int row, int column )
    void cellPressed ( int row, int column )
    void currentCellChanged ( int currentRow, int currentColumn, int previousRow, int previousColumn )
    void currentItemChanged ( QTableWidgetItem * current, QTableWidgetItem * previous )
    void itemActivated ( QTableWidgetItem * item )
    void itemChanged ( QTableWidgetItem * item )
    void itemClicked ( QTableWidgetItem * item )
    void itemDoubleClicked ( QTableWidgetItem * item )
    void itemEntered ( QTableWidgetItem * item )
    void itemPressed ( QTableWidgetItem * item )
    void itemSelectionChanged ()

    Remember the tablewidget items are not inherited from QObject and hence will NOT have signals.
    The signals can hence be tracked from the QTableWidget.


  • Hi!

    I've found this but there is a lot of confusion. Most of them are just for tracking. After looking through it again, I noticed itemChanged(QTableWidgetItem *). I completely missed it.


    Marked as solved.


Log in to reply