Search code examples
c++qtqdateedit

Change QDateEdits behaviour on select all


I am learning Qt (in C++) and I have a question regarding the QDateEdit.

I want to be able to type after selecting the text in my QDateEdit. By default you cannot type if you select the whole date. I am sure there is an easy way to do that. How can I change the behaviour to start at the beginning of my QDateEdit instead of doing nothing?

Thanks in advance


Solution

  • In case anyone else has the same problem, the solution is rather simple.

    Currently I am using the QDateTimeEdit.

    You can override the "keyPressed" method, check for "ctrl+a" and use the "setSelectedSection" method with "sectionAt(0)" which allows the user to start typing at the beginning of the QDateTimeEdit.