I inherit class from QwtScaleDraw to show date-time axis:

Qt Code:
  1. class TimeScaleDraw: public QwtScaleDraw {
  2. public:
  3.  
  4. TimeScaleDraw(const QDateTime &base) : baseDateTime(base)
  5.  
  6. {
  7. setLabelRotation(0);
  8. setLabelAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
  9. setSpacing(20);
  10. }
  11. virtual QwtText label(double v) const
  12. {
  13. QDateTime dateTime;
  14. dateTime = dateTime.fromTime_t(v);
  15. return dateTime.toString("yyyy.MM.dd\nhh:mm:ss");
  16. }
  17. private:
  18. QDateTime baseDateTime;
  19. };
To copy to clipboard, switch view to plain text mode 

In main file I use it as:

Qt Code:
  1. funPlot->setAxisScaleDraw(QwtPlot::xBottom, new TimeScaleDraw(QDateTime::currentDateTime()));
To copy to clipboard, switch view to plain text mode 

I want to see the current date-time by default when I run the app. Is it possible? Now it displays as 1970.01.00 00:00:00 with an appropriate scale.