gpt4 book ai didi

c++ - EnhTableWidget 字段的值更改(返回前)时发出信号

转载 作者:行者123 更新时间:2023-11-30 03:45:32 25 4
gpt4 key购买 nike

我有一个关于 EnhTableWidget 字段信号的问题:

  • 当我点击该表格的单元格时 -->..currentCellChanged(int,int,int,int) 被发射

  • 当我在表格的单元格中单击返回时 -->..cellChanged(int,int) 被发射

我需要在更改单元格的值时启动计算方法,但是 before 返回被按下。是否有信号,比如

当我更改该表的一个字段的值(还没有返回!)时 --> ..?? 被发出

最佳答案

创建一个自定义委托(delegate)来处理单元格编辑器发出的更改:

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;
}

关于c++ - EnhTableWidget 字段的值更改(返回前)时发出信号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34739942/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com