Wt: fatal error: bad any cast Enum
Added by Samuele Pederzini over 3 years ago
Hi,
when i modify a WtableView created by QueryModel and modify an enum field through item delegate i have this error:
[2021-May-05 09:59:03.458] 3649 [/ alEEjdNT8QcQS173] [error] "Wt: error during event handling: bad any cast"
[2021-May-05 09:59:03.458] 3649 [/ alEEjdNT8QcQS173] [error] "Wt: fatal error: bad any cast"
virtual void setModelData(const Wt::cpp17::any &editState, Wt::WAbstractItemModel* model,
const Wt::WModelIndex &index) const override
{
int stringIdx = (int)Wt::asNumber(editState);
model->setData(index, TypeContainer::Tab, Wt::ItemDataRole::Edit);
}
Replies (1)
RE: Wt: fatal error: bad any cast Enum - Added by Aziz Gokhan Narin over 3 years ago
Hello Samuele,
You should cast the data like this
int stringIdx = Wt::cpp17::any_cast(editState)