Clickable items in WTableView
Added by Ivan Bezyazychnyy over 1 year ago
Hi everyone!
I created my own OptionsModel class which inherits WAbstractItemView. I reimplemented methods: rowCount, columnCount, data, headerData, setData and flags. Model has two columns: name of an option and its value. The last is Editable. Then I created WTableView and set my new model.
And I've received a table where all items are clickable: they are blue and underlined and if I click on such item the browser tries to open page (curent page + #name of item). How can I make this items not clickable?
I've been looking for such question in forum's history but haven't found any. I thought that the trouble with flags() function but different experiments didn't help me. Now it looks like:
WFlags<ItemFlag> OptionsModel::flags(const WModelIndex &index) const
{
if (index.column() == 1)
{
return (Wt::ItemIsEditable);
}
return 0;
}
I will be glad for any tip or advise. Thanks.
Ivan Bezyazychnyy.
Replies
RE: Clickable items in WTableView - Added by Thomas Suckow over 1 year ago
Sounds like you are ignoring the role on the data(...) function.
I use the following:
if( role DisplayRole || role EditRole/* || role == ToolTipRole */)
{
return <Your data>;
}
else
{
return boost::any();
}
RE: Clickable items in WTableView - Added by Thomas Suckow over 1 year ago
Interesting, it got rid of the double equals and I didn't notice till I posted.
Take 2:
if( role == DisplayRole || role == EditRole/* || role == ToolTipRole */)
{
return <Your Data>;
}
else
{
return boost::any();
}
RE: Clickable items in WTableView - Added by Ivan Bezyazychnyy over 1 year ago
Thank you! The trouble really was with the role.