WSelectionBox is a View widget (see also
Model-View-Controller). By default a WStringListModel is used. With this model you can associate a
single column of data to the displayed items. The member
methods addItem(), insertItem() and
removeItem() manipulate the model. You can set the model
with setModel(). See the Combo box section for an example.
A model supports different roles like
Wt::ItemDataRole::UserRole. The suggestion text for an
item in the drop-down box is associated with a
Wt::ItemDataRole::DisplayRole. The value, which will be
inserted in the line-edit, corresponding with a suggestion, is
stored as Wt::ItemDataRole::UserRole) data. If no
UserRole data is available, the behaviour defaults to inserting
the suggestion text iteself.
If you want to associate multiple data columns with an item from the
combo box then you should assign another model to this control like
WStandardItemModel or an implemention of
Note that there are still other models like WFormModel which
and can be used to represent fields in a form.