QDateTimeEdit: rollback from 59 to 00 or vice-versa in hours/minute/second

浪尽此生 提交于 2019-12-22 13:53:00

问题


How can I rollback hour/min/sec from 59 to 00 or vice versa. Actually QDateTimeEdit doesn't allow it by default and it get stuck after reaching maximum value of 59 if tried pressing up arrow, and same for minimum value 00.


回答1:


You must know that QDateTimeEdit is inherit QAbstractSpinBox, and QAbstractSpinBox has wrapping mechanism, using it you can make your spins circular. So, all what you must do is

setWrapping(true)

in your case, it must be something like this: ui->dateTimeEdit->setWrapping(true);

If wrapping is true stepping up from maximum() value will take you to the minimum() value and vica versa. Wrapping only make sense if you have minimum() and maximum() values set.

See official documentation here .

Good luck!



来源:https://stackoverflow.com/questions/14212762/qdatetimeedit-rollback-from-59-to-00-or-vice-versa-in-hours-minute-second

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!