Project

General

Profile

WAbstractTableModel implementation

Added by Aleksander Fular over 11 years ago

Hello,

First, sorry for this kind of question..

I've been trying for hours just to implement my class extending abstractTableModel class.

Anyone could give me sample how to implement simple TableContainer just to display one or two WText's ?

implementations for

rowCount,

columnCount,

and data().

for example my attempt..

WidgetModel::WidgetModel(void)

{

mElement = new Wt::WText("element");

this->setData(0,0,mElement);

}

same implementation for rowCount as ColumnCount:

int WidgetModel::columnCount(const Wt::WModelIndex &index) const

{

printf("WidgetMode::ColumnCount() Called.\r\n");

if(index.isValid()) or index.internalPointer == 0 ?

return 1;

return 0;

}

data:

boost::any WidgetModel::data(const Wt::WModelIndex &index,int) const

{

printf("WidgetMode::data() Called %d %d.\r\n",index.row(),index.column());

return boost::any(mElement);

}

Any help would be deeply appreciated..


Replies (1)

RE: WAbstractTableModel implementation - Added by Aleksander Fular over 11 years ago

I finally got this.

Key was to just handle role in data function.

boost::any WidgetModel::data(const Wt::WModelIndex &index,int role) const

{

if(role 0)
{
return boost::any(Wt::WString(\"HAIHAIHAI\"));
}
else if(role 3)

{

return boost::any(Wt::WString("aaa NodeWidget"));

}

return boost::any();

}

    (1-1/1)