Bokambo
Bokambo

Reputation: 4480

How to Set Time in QTimeEdit at Run Time in QT?

How to Set Time in QTimeEdit at Run Time in QT ?

Like I want to Show 17:30 in QtimeEdit.

Thanks.

Upvotes: 3

Views: 14597

Answers (3)

Ivan Dulov
Ivan Dulov

Reputation: 87

You can apply:

bool QTime::setHMS ( int h, int m, int s, int ms = 0 )

QTime tm;
tm.setHMS(10,25,45,0);

The result will be "10:25:45"

Cheers.

Upvotes: 0

RedX
RedX

Reputation: 15175

http://doc.qt.io/qt-5/qdatetimeedit.html#time-prop What exactly did you not understand?

example:

QTime time(17, 30);
QTimeEdit te;
te.setTime(time);

Upvotes: 4

LoSciamano
LoSciamano

Reputation: 1119

You can use the following methods:

  • setTime ( const QTime & )
  • setTimeRange ( const QTime &, const QTime & )
  • setTimeSpec ( Qt::TimeSpec )

e.g.:

this->time_edit->setTime(QTime(10,17));

Upvotes: 2

Related Questions