C++ Qt编辑器问题

发布于 2024-10-07 05:39:29 字数 318 浏览 0 评论 0原文

我遇到过这样的情况:我必须手动关闭 QTableWidget 的持久编辑器。

默认情况下,关闭编辑器不会导致保存对 QTableWidgetItem 的更改(它只是丢弃它们)。

我希望将这些更改与 closePersistentEditor 调用一起保存 - 应该如何完成?

我尝试在 closePersistentEditor 调用之前发出 cellChanged >closePersistentEditor 调用 - 它没有帮助

I have the case when I have to manually close the persistent editor for the QTableWidget.

By default, closing the editor this doesn't result in saving the changes to the QTableWidgetItem (it simply discards them).

I wish to save these changes along with the closePersistentEditor call - how should it be done?

I tried emitting cellChanged before the closePersistentEditor call - it didn't help

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

夜夜流光相皎洁 2024-10-14 05:39:29

看起来你可以写这样的东西

void MyTableWidget::commitAndClosePersistentEditor(const QTableWidgetItem* item)
{
    if (!item)
        return;

    QModelIndex index = indexFromItem(item);
    QWidget* editor = indexWidget(index);
    commitData(editor);
    closePresistentEditor(item);
}

Looks like you can write something like this

void MyTableWidget::commitAndClosePersistentEditor(const QTableWidgetItem* item)
{
    if (!item)
        return;

    QModelIndex index = indexFromItem(item);
    QWidget* editor = indexWidget(index);
    commitData(editor);
    closePresistentEditor(item);
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文