如何将 WComboBox 建模为 WFormModel 字段?

How to model a WComboBox as a WFormModel field?

我有一个正在运行的 MVC 表单,它使用由 WFormModel 支持的 WTemplateFormView,带有一组 WDoubleSpinBox 字段和一个提交按钮。 (这是一个计算器。)

我想在表单中添加一个组合框,但我不确定如何处理 WFormModel 中的字段。

我查看了示例(http://www.webtoolkit.eu/widgets/forms/combo-box,在 "Model" 标题下),但它似乎不是我想要的;它从来没有提到 "fields"(在 WFormModel 中很普遍),它有这样的声明:"Note that there are still other models like WFormModel which and [sic] can be used to represent fields in a form".

有人可以解释如何使用由 WFormModel 字段支持的 WComboBox 吗?或者更好的是,网络上是否有某个示例?

您可以在 http://www.webtoolkit.eu/widgets/forms/integration-example

找到 WFormModel 和 WTemplateFormView 的实例

您可以在 https://github.com/kdeforche/wt/blob/master/examples/widgetgallery/examples/FormModel.cpp

找到它的源代码

在 WFormModel 中,您必须使用 WFormModel::addField() and in the WTemplateFormView you can set WComboBox or any other widget as a field widget using WTemplateFormView::setFormWidget()

将字段添加到字段列表