Project

General

Profile

Feature #4358 » 0004-Updated-ChartsExample.C-for-tooltip-testing.patch

Bruce Toll, 07/29/2015 01:42 AM

View differences:

examples/charts/ChartsExample.C
for (int col = 0; col < model->columnCount(); ++col) {
model->item(row, col)->setFlags(ItemIsSelectable | ItemIsEditable);
/*
Example of tool tips (disabled here because they are not updated
when editing data)
*/
/*
WString toolTip = asString(model->headerData(col)) + ": "
+ asString(model->item(row, col)->data(DisplayRole), "%.f");
model->item(row, col)->setToolTip(toolTip);
*/
}
model->itemChanged().connect(std::bind([=] (WStandardItem *item) {
WString old_tip = item->toolTip();
WString new_tip = asString(model->headerData(item->column())) + ": "
+ asString(item->data(DisplayRole), "%.f");
if (old_tip != new_tip) {
item->setToolTip(new_tip);
}
}, std::placeholders::_1));
return model;
} else {
WString error(WString::tr("error-missing-data"));
......
model->setData(i, 0, x);
model->setData(i, 1, sin(x));
WString toolTip = asString(model->item(i, 1)->data(DisplayRole), "%.2f");
model->item(i, 1)->setToolTip(toolTip);
}
/*
(4-4/5)