QListView& QStandardItemModel在编辑行之前检查文本 [英] QListView & QStandardItemModel check text before editing row
问题描述
我想在用户编辑之前检查 QListView
中的一行的文本。如果它不适合一个模式,我不想接受它。
目前我有一个 QListView
和 QStandardItemModel
。我可以通过 QStandardItemModel
轻松添加和删除项目。我还设置了列表视图的模型。
是否有一些代表
或事件
您可以重载<$列表或模型上的从 QStandardItemModel
的c $ c> data()和 setData()
用户尝试编辑项目,您的 setData
将使用 Qt :: EditRole
调用,您可以进行处理。 / p>
http ://qt-project.org/doc/qt-5.0/qtcore/qabstractitemmodel.html#setData
I want to check the text of a row in QListView
before the user is editing it. If it doesn't fit a pattern, I don't want to accept it.
Currently I have a QListView
and QStandardItemModel
. I can easily add and remove items via the QStandardItemModel
. I also set the model of the list view.
Are there some delegates
or event
function(s) on the list or the model for editing?
you can overload data()
and setData()
functions from QStandardItemModel
, then when user tries to edit item your setData
will be called with Qt::EditRole
and there you can do your processing.
http://qt-project.org/doc/qt-5.0/qtcore/qabstractitemmodel.html#setData
这篇关于QListView& QStandardItemModel在编辑行之前检查文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!