How to implement a custom keyboard(old cellphone like)?

I'm using Qt5.8 on a embedded linux device and I need to implement a custom keyboard. The behaviour is the same of that old cellphones keypads where each time you press a digit button repeatedly it becomes a different letter. For example: