Results 1 to 3 of 3

Thread: Substract two QStrings

  1. #1
    Join Date
    Oct 2015
    Location
    Barcelona, Spain
    Posts
    7
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Windows Android

    Default Substract two QStrings

    Hi,
    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!
    Last edited by Alberto7; 26th October 2015 at 14:36. Reason: spelling corrections

  2. #2
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,456
    Thanked 271 Times in 266 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Substract two QStrings

    Qt Code:
    1. QString str_1 = "11:00";
    2. QString str_2 = "10:00";
    3. QString result = str_1 + " - " + str_2;
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,396
    Thanks
    37
    Thanked 1,542 Times in 1,493 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Substract two QStrings

    In case you want to calculate the time difference, see QTime::fromString().

    Cheers,
    _

Similar Threads

  1. QGraphicsRectItem with list of QStrings
    By January in forum Newbie
    Replies: 4
    Last Post: 24th April 2012, 20:04
  2. Can't declare more than 7 QStrings ?!?!?!
    By ruben.rodrigues in forum Newbie
    Replies: 8
    Last Post: 21st July 2010, 14:42
  3. concatenating path QStrings
    By rbp in forum Qt Programming
    Replies: 2
    Last Post: 19th December 2008, 04:46
  4. QSettings on QStrings
    By OriginalCopy in forum Qt Programming
    Replies: 4
    Last Post: 4th November 2007, 10:57
  5. dynamic matrix of QStrings
    By QiT in forum Newbie
    Replies: 19
    Last Post: 4th April 2007, 09:26

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.