Project

General

Profile

Wt 3.3.9 WItemDelegate that creates a WComboBox with setNoSelectionEnabled(true) in virtual createEditor

Added by robs j about 6 years ago

I have a derived WItemDelegate that creates a WComboBox in a WContainerWidget

Wt::WWidget* MyDelegate::createEditor(const Wt::WModelIndex &index,

Wt::WFlagsWt::ViewItemRenderFlag flags) const

{

auto container = new Wt::WContainerWidget();

auto combo = new Wt::WComboBox(container);

combo->setNoSelectionEnabled(true);

combo->setModel(items_);

combo->changed().connect(boost::bind(&MyDelegate::doCloseEditor, this, container, true));

combo->enterPressed().connect(boost::bind(&MyDelegate::doCloseEditor, this, container, true));

combo->escapePressed().connect(boost::bind(&MyDelegate::doCloseEditor, this, container, false));

}

The delegate is used in a derived WAbstractTableModel via setItemDelegateForColumn()

I am able to choose one of the items but since I added "combo->setNoSelectionEnabled(true);" I have problems with closing the created widget.

I have searched and found https://redmine.emweb.be/issues/5145. But the order does not solve my issue.

Does anyone has a suggestion what is wrong with my code?

Thank you very much for your help.


Replies (3)

RE: Wt 3.3.9 WItemDelegate that creates a WComboBox with setNoSelectionEnabled(true) in virtual createEditor - Added by lm at about 6 years ago

I haven't done anything like this, so a minimum working example would be necessary. Maybe someone else on this forum can help though.

RE: Wt 3.3.9 WItemDelegate that creates a WComboBox with setNoSelectionEnabled(true) in virtual createEditor - Added by robs j about 6 years ago

For further details of the implementation see the example in wt widgetgallery ComboDelegateTable.cpp.

Just add the line

combo->setNoSelectionEnabled(true);

to the protected method

virtual Wt::WWidget* createEditor(const Wt::WModelIndex &index,

Wt::WFlagsWt::ViewItemRenderFlag flags) const

RE: Wt 3.3.9 WItemDelegate that creates a WComboBox with setNoSelectionEnabled(true) in virtual createEditor - Added by Roel Standaert about 6 years ago

It seems to work fine in Wt 3.3.10 RC 1. Maybe it's been fixed, not sure. Can you check?

    (1-3/3)