Search code examples
qtqwidget

QDateTimeEdit focus to seconds


I have a QDateTimeEdit widget in my dialog showing minutes and seconds in the form of mm:ss

When the widget get focus by clicking the up/down arrows the minutes are increased/decreased by default. Is there a way to set default focus to the seconds?

enter image description here


Solution

  • In the QDateTimeEdit, there is a method named setCurrentSection(). All you have to do is to set the current selection to the seconds, like this:

    dateTimeEdit->setCurrentSection(QDateTimeEdit::SecondSection);