Project

General

Profile

About insert information in WAbstractItemModel for a graphic

Added by Roberto Rodríguez Reyes almost 14 years ago

As you enter data to pie charts, bar and lines?. If I could give an example in which no data is loaded from a. Csv or. Txt, I would be very useful to show me how to insert the information from a list or an array I have.

Thank you very much and greetings


Replies (3)

RE: About insert information in WAbstractItemModel for a graphic - Added by Pieter Libin almost 14 years ago

Dear Roberto,

I will adapt the chart example in a way the pie chart's model is built using code (not from CSV).

When I fininsh I will post the code here.

Pieter

RE: About insert information in WAbstractItemModel for a graphic - Added by Roberto Rodríguez Reyes almost 14 years ago

Thank you very much, I am looking forward to the new variant you will use, I need to graduate, because my thesis is using Wt. Best regards

Roberto

RE: About insert information in WAbstractItemModel for a graphic - Added by Pieter Libin almost 14 years ago

Dear Roberto,

the following code creates the model used by the pie chart example manually,

it will be pushed to the public git soon.

WStandardItemModel *model = new WStandardItemModel(this);

//headers

model~~insertColumns(model~~>columnCount(), 2);

model->setHeaderData(0, boost::any(WString("Item")));

model->setHeaderData(1, boost::any(WString("Sales")));

//data

model~~insertRows(model~~>rowCount(), 6);

int row = 0;

model->setData(row, 0, boost::any(WString("Blueberry")));

model->setData(row, 1, boost::any(120));

row;

model->setData(row, 0, boost::any(WString("Cherry")));

model->setData(row, 1, boost::any(30));

row;

model->setData(row, 0, boost::any(WString("Apple")));

model->setData(row, 1, boost::any(260));

row;

model->setData(row, 0, boost::any(WString("Boston Cream")));

model->setData(row, 1, boost::any(160));

row;

model->setData(row, 0, boost::any(WString("Other")));

model->setData(row, 1, boost::any(40));

row;

model->setData(row, 0, boost::any(WString("Vanilla Cream")));

model->setData(row, 1, boost::any(120));

row;

//set all items to be editable and selectable

for (int row = 0; row < model->rowCount(); ++row)

for (int col = 0; col < model->columnCount(); ++col)

model~~item(row, col)~~>setFlags(ItemIsSelectable | ItemIsEditable);

    (1-3/3)