0

I´m trying to substract two hours.

QString 1 = "11:00";
QString 2 = "10:00";

I would like to save the result from (11:00 - 10:00) into another QString.

Does anyone know how could I do this?

Thanks for replying!

Joe Taras
  • 15,166
  • 7
  • 42
  • 55
Alberto7
  • 51
  • 1
  • 7

1 Answers1

0

I would use QTime:

Convert your QStrings to QTime:

QTime a = QTime::fromString("11:00", "HH:mm");  
QTime b = QTime::fromString("12:00", "HH:mm");

Get difference in msecs:

int differenceInMsecs = a.msecsTo(b);

(Read QTime:msecsTo() documentation!)

Convert msecs ins whatever you want and put it in QString

JSilver
  • 107
  • 6