QTableWidget. Emit CellChanged signal
You should use connect
to catch signal
cellChanged(int,int)
on cell change:
connect(yourTableWidget, SIGNAL(cellChanged(int, int)), this, SLOT(doSomething(int, int)));
You need to create 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 a signal somethingIsDone
(or use an existing signal) that uses ( int,int,QString
) parameters (parameters can be in a different order)
signals:
void somethingIsDone(int row, int column, QString text);
source to share
You have to make a slot function and use QObject :: connect to connect to the signal cellChanged
.
For example:
QTableWidget* widget;
widget = new QTableWidget(this);
connect(widget, SIGNAL(cellChanged(int, int)), otherObject, SLOT(youSlot(int, int));
In your slot, you can get the QTableWidgetItem using the received parameters: row and column number. And here you can emit your own signal containing text as well.
QTableWidgetItem* item = widget->item(row, column); QString textFromItem = item->data(Qt::UserRole); emit cellChanged(row, column, textFromItem);
Of course, earlier you must declare your own signal:
signals:
void cellChanged(int row, int col, QString text);
Your signal can be connected to another slot in the same way as cellChanged(int, int)
source to share