Qt:如何更新模型?
我正在尝试在我的应用程序中使用模型视图方法。我有一个充满数据的 TableView。我有几个外部字段可以编辑数据。一旦我单击该行,我就会从表视图的字段中获取数据并将其放入外部字段中。然后我希望当我单击按钮时,表视图中的数据可以从字段中更新。怎么做呢?
谢谢
I'm trying to use Model-View approach in my app. I have a TableView that is filled by data. And I have several outside fields to edit data. As soon as I click the row I take the data from tableview's field and put into outside field. Then I want when I click the button the data into tableview to be updated from the field. How to do that?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
![扫码二维码加入Web技术交流群](/public/img/jiaqun_03.jpg)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
QAbstractItemModel
有一个信号QAbstractItemModel::dataChanged(const QModelIndex & topLeft, const QModelIndex & BottomRight)
当 Item 更改时您需要发出。QAbstractItemView
有一个插槽QAbstractItemView::update(const QModelIndex 和索引)
,您可以调用它来更新单元格中的项目QAbstractItemModel
has a signalQAbstractItemModel::dataChanged(const QModelIndex & topLeft, const QModelIndex & bottomRight)
that you need to emit when an Item is changed.QAbstractItemView
has a slotQAbstractItemView::update(const QModelIndex & index)
that you can call to update an item in a cell