2

In my application I have a QTimeEdit, in which I only want to edit the hours. Is it possible to do that? (Disable editing of minutes)

erniberni
  • 313
  • 5
  • 17

1 Answers1

2

You could override void QDateTimeEdit::stepBy(int steps) to add/remove hours only.

Though the Qt code seems a bit complicated for that task : https://code.woboq.org/qt5/qtbase/src/widgets/widgets/qdatetimeedit.cpp.html#_ZN13QDateTimeEdit6stepByEi

ymoreau
  • 3,402
  • 1
  • 22
  • 60
  • Oh, yep, it seems really complicated...I think I will look for another solution or let it be possible to edit hours and minutes :D. Nevertheless, thanks for the answer! – erniberni Jan 09 '18 at 06:09
  • Actually the code is complicated because it handles date and time and different options of the input. But if you want some clear and less flexible behaviour like : step-up adds 1h, step-down removes 1h, it might be less complicated, sadly I have no time to try to make an example at the moment – ymoreau Jan 09 '18 at 08:50
  • At the moment it is not that bad, wenn I can set the minutes too. Maybe I will have a look at this at a later time :) – erniberni Jan 09 '18 at 09:33