PDA

View Full Version : time and date issues



boog07005
4th January 2007, 00:02
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

munna
4th January 2007, 05:24
There are widgets like QTimeEdit (http://doc.trolltech.com/3.3/qtimeedit.html), QDateEdit (http://doc.trolltech.com/3.3/qdateedit.html) and QDateTimeEdit (http://doc.trolltech.com/3.3/qdatetimeedit.html) which you can use for all your time and date related inputs and then you can do all your calculations.

Brandybuck
4th January 2007, 07:59
The time and date spinboxes will QDate, QTime and QDateTime classes you can access. These will give you all the time information you need.

hemapriya
19th August 2012, 07:00
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);

BalaQT
20th August 2012, 14:58
try daysTo() function.
Ex:


QDate date1;
QDate date2;
int nDiff = date1.daysTo(date2);
ui->line_edit->setText(QString::number(nDiff));




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


hope it helps

spirit
20th August 2012, 15:15
I'm really surprised how your compiler built this line


...
int diff=e-s;
Qstring d=diff.toString(); //<----
...