Results 1 to 6 of 6

Thread: time and date issues

  1. #1
    Join Date
    Dec 2006
    Posts
    1
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default time and date issues

    this question probanly has more to do with my lack of knowledge than anything else, but the lack is real!
    , I work for a railroad as a conductor and have been trying to produce a program thta will handle time card submittals in a complex work rule environment.

    The problem is working with time calculations. Am I wasting my time tryng to use the time edit functons in QT since I don't know how to access the elements of the widgets ,or should I just set up fields for the user to enter hours and minutes. i.e , no spin boxes

  2. #2
    Join Date
    Jan 2006
    Posts
    667
    Thanks
    10
    Thanked 80 Times in 74 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: time and date issues

    There are widgets like QTimeEdit, QDateEdit and QDateTimeEdit which you can use for all your time and date related inputs and then you can do all your calculations.

  3. #3
    Join Date
    Mar 2006
    Location
    Mountain View, California
    Posts
    489
    Thanks
    3
    Thanked 74 Times in 54 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: time and date issues

    The time and date spinboxes will QDate, QTime and QDateTime classes you can access. These will give you all the time information you need.

  4. #4
    Join Date
    Aug 2012
    Location
    BANGALORE
    Posts
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: time and date issues

    i have a doubt..pls help..

    i have 2 QDateEdits..ie one s start_date and other is end_date..i want to find difference between them and display in a QLineEdit..how to do it?

    i did
    int s=ui->start_date.day();
    int e=ui->end_date.day();
    int diff=e-s; //this works correctly it returns the difference
    Qstring d=diff.toString(); //here am getting junk values y?

    ui->line_edit->setText(d);

  5. #5
    Join Date
    Aug 2009
    Location
    coimbatore,India
    Posts
    314
    Thanks
    37
    Thanked 47 Times in 43 Posts
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: time and date issues

    try daysTo() function.
    Ex:
    Qt Code:
    1. QDate date1;
    2. QDate date2;
    3. int nDiff = date1.daysTo(date2);
    4. ui->line_edit->setText(QString::number(nDiff));
    To copy to clipboard, switch view to plain text mode 


    Qstring d=diff.toString(); //here am getting junk values y?
    you need to convert the int to string ().


    hope it helps

  6. #6
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: time and date issues

    I'm really surprised how your compiler built this line
    Qt Code:
    1. ...
    2. int diff=e-s;
    3. Qstring d=diff.toString(); //<----
    4. ...
    To copy to clipboard, switch view to plain text mode 
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

Similar Threads

  1. How to get a vaild mail time GMT?
    By patrik08 in forum Qt Programming
    Replies: 2
    Last Post: 31st May 2006, 21:16

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.