Good afternoon,

I am facing a similar situation.
A database of power consumption readings.
Basically it consists of two tables (one with different meters and one with readings).

I have just installed qwt 6.1rc2 because it seems to have some useful features for this.

Actually the code (not elegant but ok for a beginner, I hope) works and gives me a graph.
Unfortunately the x-axis is totally cryptic. I am still struggling with QwtDateScaleEngine and QwtDateScaleDraw.

However, maybe the first part helps and maybe somebody gives me a hint about the usage of the scale engine and scale draw:

Qt Code:
  1. model->setTable("tbl_zaehlerstaende"); // table with meter readings
  2. model->setRelation(2, QSqlRelation("tbl_zaehler", "zaehler_ID", "name")); //QSqlRelationalTableModel to link the two tables
  3. model->setFilter("name = 'my_meter'"); //show only my own consumption
  4. model->sort(1, Qt::AscendingOrder); //sort in chronological order
  5. model->select();
  6.  
  7. ui->tv_overview->setModel(model);
  8. ui->tv_overview->setItemDelegate(new QSqlRelationalDelegate(ui->tv_overview));
  9. ui->tv_overview->show();
  10.  
  11.  
  12.  
  13.  
  14. int k = model->rowCount(); //number of datapoints, ie readings
  15. QVector<QPointF> datapoints;
  16.  
  17.  
  18.  
  19.  
  20. for (int i = 0; i < k; i++)
  21. {
  22.  
  23. QDateTime date; //the format in MySql is actually just DATE, but it does not seem to matter
  24. date = (model->data(model->index(i,1))).toDateTime();
  25.  
  26. qreal x;
  27.  
  28. x = QwtDate::toDouble(date); //qwt needs a double to work
  29.  
  30.  
  31.  
  32. datapoints.append(QPointF(x, qreal(model->data(model->index(i,3)).toInt())));
  33.  
  34. }
  35.  
  36. QwtPlotCurve *curve = new QwtPlotCurve();
  37.  
  38. curve->setSamples(datapoints);
  39. curve->attach(ui->qwt_plot);
  40.  
  41. ui->qwt_plot->replot();
To copy to clipboard, switch view to plain text mode 

Really I used google, I read the documentation. But I find it hard to get started.

Many greetings,

RogerWilco