开发者

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

开发者 https://www.devze.com 2023-03-11 03:41 出处:网络
How to Set Time in QTimeEdit at Run开发者_Python百科 Time in QT ? Like I want to Show 17:30 in QtimeEdit.

How to Set Time in QTimeEdit at Run开发者_Python百科 Time in QT ?

Like I want to Show 17:30 in QtimeEdit.

Thanks.


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);


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));


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号