Bug #5510 » 0001-Add-tool-tips-to-charts-example.patch
examples/charts/ChartsExample.C | ||
---|---|---|
for (int col = 0; col < model->columnCount(); ++col) {
|
||
model->item(row, col)->setFlags(ItemFlag::Selectable | ItemFlag::Editable);
|
||
/*
|
||
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");
|
||
+ asString(model->item(row, col)->data(ItemDataRole::Display), "%.f");
|
||
model->item(row, col)->setToolTip(toolTip);
|
||
*/
|
||
}
|
||
auto model_p = model.get();
|
||
model->itemChanged().connect([model_p] (WStandardItem *item) {
|
||
WString old_tip = item->toolTip();
|
||
WString new_tip = asString(model_p->headerData(item->column())) + ": "
|
||
+ asString(item->data(ItemDataRole::Display), "%.f");
|
||
if (old_tip != new_tip) {
|
||
item->setToolTip(new_tip);
|
||
}
|
||
});
|
||
return model;
|
||
} else {
|
||
... | ... | |
model->setData(i, 0, x);
|
||
model->setData(i, 1, sin(x));
|
||
WString toolTip = asString(model->item(i, 1)->data(ItemDataRole::Display), "%.2f");
|
||
model->item(i, 1)->setToolTip(toolTip);
|
||
}
|
||
|
||
/*
|