I want to set a time in the QTimeEdit widget longer than 23:59:59.999 . Judging by the documentation it is impossible to do. Therefore, I created a descendant of this class and redefined the function:

 QValidator::State validate(QString & text, int & pos) const 

Now I can write in the widget using the keyboard, for example, 00:00:999 . But when I switch to another widget, then the time is reset to 00:00:00 . Using the arrows and the mouse wheel, it is also impossible to increase the component time values ​​more than permissible.

What methods still need to reboot?

  • I'm afraid you will have to tinker with this class and not the fact that something will come of it. He just is not intended for this. Easier to write your widget, most likely. - ixSci

1 answer 1

The value is reset to 00:00:00, because The widget text you entered tries to convert to QDateTimeEdit . Try to inherit QLineEdit and set the input mask: QLineEdit::setInputMask("DDD:DDD:DDD") Next, redefine the events you need, which will change the current section, which can be determined based on QLineEdit::cursorPosition()