PDA

View Full Version : How do i get the number of hours



ayanda83
4th January 2013, 09:59
I have two QTimeEdit objects and i want to calculate the number of hours between QTimeEdit1 and QTimeEdit2. How can i hdo that?

Santosh Reddy
4th January 2013, 10:20
QTimeEdit *timeEdit1;
QTimeEdit *timeEdit2;

QTime time1 = timeEdit1->time();
QTime time2 = timeEdit2->time();

int hours = time2.secsTo(time1) / 60 / 60;
// -24 < hours < 24

wysota
4th January 2013, 10:21
QTime::secsTo()