System.Windows.Forms.BindingSource 是否等同于 QSortFilterProxyModel?

Is System.Windows.Forms.BindingSource equivalent to QSortFilterProxyModel?

来自 Qt,在我看来 BindingSource class 提供相同的功能,并且旨在以与 Qt 中的 QSortFilterProxyModel 相同的方式使用。

阅读 When is it worth using a BindingSource? 及其答案后:

Filtering,Sorting while not changing the sort order of the records themselves (Filter/Sort)

还有:

A BindingSource can act as a data source of another BindingSource

这些与 Qt 中的 QSortFilterProxyModel 提供的功能相同。

有 Qt 和 Winforms 经验的人可以告诉我我的理解是否正确,如果不正确,使用 BindingSource 和 QSortFilterProxyModel 的最大区别是什么?

我不是 winforms 专家,但通过阅读它,它们既相似又不同。

这里是我的 QSortFilterProxyModel 的关键概念。这其中有多少适用于 BindingSource 或不同之处我不能告诉你太多。

  • Qt 中的 ProxyModels 是在您的基本模型之上分层的抽象模型(这里似乎与 BindingSource 一样)。虽然您不能向其中添加控件等,因为它们就是这样:数据模型。您可以将此 ProxyModel 或普通模型附加到视图,此视图负责显示哪些控件(尽管模型可以提供 "hints")。

  • SortFilterProxyModel 也可以基于字符串对数据进行排序和过滤。您可以从中派生自定义 sorting/filter。无货币管理等

  • Qt 还鼓励使用这种方法编写您自己的 ProxyModel(如果需要)(您也可以将多个 ProxyModel 叠加在一起)。 这与 BindingSources 有多少不同,您可以自定义多少我不知道

  • 可以通过 Qt 中常用的信号和槽概念来管理更改通知,尽管这里的责任在于 ProxyModel 下面的模型而不是 ProxyModel。

结论:看来他们有类似的概念,并且都(偶然)支持排序和过滤(可能因为它只是一个很常见的用例),但是它们所使用的模型-视图系统的基本概念似乎完全不同。

同样,这是没有任何或非常粗略的 winforms 知识,也许其他人可以回答这部分,然后你就有了一个很好的比较。