QTableWidget. Emit cellChanged signal

Ufx picture Ufx · Sep 26, 2014 · Viewed 8.6k times · Source

There is QTableWidget. I need to send cellChanged signal with row column and text. How can I do this?

--

I have already connected signal with slot. I need to send signal.

Answer

Rémi picture Rémi · Sep 26, 2014

You have to use connect to catch signal cellChanged(int,int) when a cell is changed:

connect(yourTableWidget, SIGNAL(cellChanged(int, int)), this, SLOT(doSomething(int, int)));

You have to create a slot, for example doSomething:

public slots:
void doSomething(int row, int column)
{
    // Get cell text
    QString text = yourTableWidget->item(row,column)->text();

    // Emit 
    emit somethingIsDone(row,column,text);
}

Create the signal somethingIsDone (or use an existing signal) which use (int,int,QString) parameters (the parameters could be in another order)

signals:
    void somethingIsDone(int row, int column, QString text);