十
10
Plus Your Qt
十
10
AutoAdvance, is a feature that allows you step up or down in whole sections. For example, when 4:59 and you try to step up, you will get 5:00, when the feature is enabled.
This is a useful feature but disappeared since Qt 3.3. And below, is my own method to implement it.
class myTime : public QTimeEdit
{
Q_OBJECT
public:
virtual void stepBy(int steps)
{
if (this->time().minute()==59 && steps>0){
setTime(QTime(time().hour()+1,0,time().second(),time().msec()));
}else if(this->time().minute()==00 && steps<0){
setTime(QTime(time().hour()-1,59,time().second(),time().msec()));
}else{
QTimeEdit::stepBy(steps);
}
}
};
Keep in mind, to enable the code beyond, must setWrapping(true).
Designed by Tim Sainburg from Brambling Design