过滤模型尽量不要用正规表达式
时间:2009-06-21 来源:feiyinglinux
- void setFilterRegExp ( const QRegExp & regExp )
- void setFilterRegExp ( const QString & pattern )
以上是两个基于正规表达式的过滤,如果有特殊字符,可能会出问题。
如过滤的内容是tr("abc."), . 在正则表过式里,代表通配符,这样,就会把所有前面三个字符是abc的项目都显示出来。
建议用下面的这个函数
void QSortFilterProxyModel::setFilterFixedString ( const QString & pattern ) [slot]
Sets the fixed string used to filter the contents of the source model to the given pattern.
相关阅读 更多 +