Hi,

I'm making a qwtplot and I am setting the xaxis with some dates using QwtScaleDraw, I have a few questions about the implementation.

First, when I load the data I want the first Xaxis date to be the date of the first y value, but it always ends up being a few days before it, I think this is because the plot background is bigger than the data(which I want to keep). How can I get the first QwtScaleDraw label to correspond with my first y value?

Second, and this is more a general qt/c++ question, is there a better way to get my values in my QwtScaleDraw into human-readable format? Right now I am doing some funky stuff: I take the double value (which is date in unix GMT) then i use ctime to convert it to a char*. Ctime converts my unix GMT to local time, which I don't want (I want it to stay GMT). So I add the seconds that my time is differnt from GMT to the value and then call ctime. There has got to be a better way!


Qt Code:
  1. class xAxisDates: public QwtScaleDraw
  2. {
  3. public:
  4. xAxisDates()
  5. {
  6. setSpacing(15);
  7. }
  8. virtual QwtText label(double value) const
  9. {
  10. double diff = 7*60*60 //7hrs*60min*60sec - how far my timezone is from GMT
  11.  
  12. time_t valueInGmt = value;
  13. time_t gmtPlusDiffForLocal = value+diff;
  14.  
  15. char * humanTime = ctime(&(gmtPlusDiffForLocal)); //bad form: I add offset to gmt time becuase i use ctime to convert to char*
  16.  
  17. return QString(humanTime);
  18. }
  19. };
  20. /////
  21. setAxisScaleDraw(QwtPlot::xBottom, new xAxisDates);
  22. ////
To copy to clipboard, switch view to plain text mode 

this is where I load up the data and where QwtScaleDraw gets its value:
Qt Code:
  1. void plotFile( double st, double end)
  2. {
  3. newNumbPts = //num of pts in the file
  4. int newNumbPts = endIDX - stIDX;
  5. cout << "newnumb pts: "<< newNumbPts << endl;
  6. t = new double[newNumbPts];
  7. v = new double[newNumbPts];
  8. double *tempT = t;
  9. double *tempV = v;
  10.  
  11. fseek(fp, stIDX*2*sizeof(double), SEEK_SET);
  12. for( int i=0; i<newNumbPts; i++){
  13. int j = fread(tempT, sizeof(double), 1, fp);
  14. int k = fread(tempV, sizeof(double), 1, fp);
  15. tempT++;
  16. tempV++;
  17. }
  18. Curve->setRawSamples(t, v, newNumbPts);
  19.  
  20. };
To copy to clipboard, switch view to plain text mode 

Any ideas?
Thanks