Err, well, how about if you convert the the datetime to seconds and then use the seconds as a coordinate value?
Something like this:
QDateTime intervalStart
= /* some start date time value */;
QDateTime intervalEnd
= intervalStart.
addDays( 3 );
int maxTimeLength = intervalStart.secsTo( intervalEnd );
int maxPixelLength = 3000;
double pixelPerSecond = (double)maxPixelLength / maxTimeLength;
// then convert each event's time to x-coordinate as pixels
someEventCoordinateX = intervalStart.secsTo( someEventDateTime ) * pixelPerSecond;
QDateTime intervalStart = /* some start date time value */;
QDateTime intervalEnd = intervalStart.addDays( 3 );
int maxTimeLength = intervalStart.secsTo( intervalEnd );
int maxPixelLength = 3000;
double pixelPerSecond = (double)maxPixelLength / maxTimeLength;
// then convert each event's time to x-coordinate as pixels
someEventCoordinateX = intervalStart.secsTo( someEventDateTime ) * pixelPerSecond;
To copy to clipboard, switch view to plain text mode
Bookmarks