currentCellChanged(int,int,int,int)
is emitted当我在桌子的单元格中返回时 - > .. cellchanged(int,int)发出
我需要在更改单元格的值时启动计算方法,但是按下了当我更改字段的值时(尚未返回!)
创建一个定制的代表,该定制代表会由单元编辑器发出变化:MyDelegate::MyDelegate(QObject *parent) : QStyledItemDelegate(parent)
{
}
QWidget* MyDelegate::createEditor(QWidget* parent,const QStyleOptionViewItem &option,const QModelIndex &index) const
{
// Assume you want a QLineEdit editor for the QTableWidget cell
QLineEdit* editor = new QLineEdit(parent);
// Get notified when editor changes
QObject::connect(editor, &QLineEdit::textEdited, this, [=](const QString &newValue) {
qDebug() << "Cell has changed without pressing return: " << newValue;
}
return editor;
}
ITEMCHANGED
信号发射
void QTableWidget::itemChanged(QTableWidgetItem * item)
此外,您也可以尝试捕获从qabstractitemview class
void QAbstractItemView::dataChanged(const QModelIndex & topLeft, const QModelIndex & bottomRight, const QVector<int> & roles = QVector<int> ())
或者您可以亚类qtablewidget和重新进化