Ich habe das "Chart Example" geändert:
http://doc.trolltech.com/4.2/itemviews-chart.html
Aber es funktioniert nur das erste Mal, wenn ich neue Daten hinein reiche.
(Das heißt, nur der Anruf von Constructor funktioniert.)
Danach ändert sich das Kreisdiagramm gar nicht, auch wenn neue Daten immer geschickt werden.
Wie kann man das verbessern?
In graphwidget.cpp:
Code: Alles auswählen
graphWin->showChart2nd(nodes.count(), node->phiInOriginal);Code: Alles auswählen
GraphWindow::GraphWindow()
{
showChart2nd(8, phiInLocal);
}
void GraphWindow::showChart2nd(int nodeSize, double phiInChart)
{
model->removeRows(0, model->rowCount(QModelIndex()), QModelIndex());
for (int row=0; row<nodeSize; row++)
{
phiInChart += row; // just to show different values
model->insertRows(row, 1, QModelIndex());
model->setData(model->index(row, 0, QModelIndex()), "Whatever");
model->setData(model->index(row, 1, QModelIndex()), phiInChart); // this is the value I would like to show
model->setData(model->index(row, 0, QModelIndex()), QColor("#99e600"), Qt::DecorationRole);
}
setWindowTitle(tr("Chart"));
resize(640, 480);
}