@SGaist said in Using different Views with one model and different data:
Ok, good.
So at what point are you now ?
After reading you question I had a new idea (before I thought it is not possible to use KDChart to plot) :D :
a data class which stores all the data
a table model which stores a pointer to the data which I would like to display.
In this model I reimplement the data, rowcount and columncount function as following:
class Data
{
public:
QVector<double>* getDataPointer(int index){return &m_data.at(index);}
private:
QVector<QVector<double>> m_data;
};
// Every Diagram uses an object of this class
class SignalModel: public QAbstractTableModel
{
public:
- override rowcount
- override columncount
- override data
void addData(QVector<double>* xaxis, QVector<double>* yaxis);
private:
QVector<QVector<double>*> m_data;
};
void SignalModel::addData(QVector<double>* xaxis, QVector<double>* yaxis){
// KDChart expects, that the axis keys and values are stored in different rows
m_data.append(xaxis);
m_data.append(yaxis);
}
int SignalModel::rowCount(const QModelIndex &parent) const {
return m_data.lenght();
}
int SignalModel::columnCount(const QModelIndex &parent) const{
int column = m_data.at(0)->length()
return column;
}
QVariant SignalModel::data(const QModelIndex &index) const{
return m_data.at(index.row)->at(index.column);
}
removeRow and insertRow must be reimplemented too, to add dynamically new data.
For showing the signal names I would reimplement a listmodel.
I think it is the simplest method to do my task. (If there are errors in my code, it is because I didn't tested it, it's just a sketch).
I found kst-plot which does exactly what I want. So I think it is easier to extend this program and help to contribute to this one, than rewriting a new one.
Thank you SGaist for your help and the inspiration. If this last concept is unclear, just write and I will extend it.