Qt删除QTableView中的选定行 [英] Qt Delete selected row in QTableView

查看:685
本文介绍了Qt删除QTableView中的选定行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我单击delete按钮时,我想从表中删除选定的行.

I want to delete a selected row from the table when I click on the delete button.

但是我在Qt文档中找不到有关删除行的任何信息.有什么想法吗?

But I can't find anything regarding deleting rows in the Qt documentation. Any ideas?

推荐答案

您可以为此使用bool QAbstractItemModel::removeRow(int row, const QModelIndex & parent = QModelIndex())功能.

在这里您可以找到示例.

此外,这是该文档的内联报价:

Also, here is an inline quote from that documentation:

removeRows()

removeRows()

用于删除行及其包含的数据项 来自所有类型的模型.实现必须调用beginRemoveRows() 在将新列插入任何基础数据结构之前,以及 此后立即致电endRemoveRows().

Used to remove rows and the items of data they contain from all types of model. Implementations must call beginRemoveRows() before inserting new columns into any underlying data structures, and call endRemoveRows() immediately afterwards.

任务的第二部分是将按钮的点击信号连接到为您执行移除操作的插槽上.

The second part of the task would be to connect the button's clicked signal to the slot executing the removal for you.

这篇关于Qt删除QTableView中的选定行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆