[Solved] Software Keyboard in QT

  • Dear All,

    I am developing an onscreen keyboard using QT. It looks similar to the hardware QWERTY keyboard.
    I want to do following:

    On press of CAPS button, all the buttons should display capital letters. and vice versa.

    What is the best suitable approach to achieve this functionality.

    Kindly give your suggestions.


  • Create a different widgets with Capital letters & Small letters. Switch between these visual elements or get the existing text and convert it to Upper or *Lower *based on the condition.
    In summery there is no direct easy way of doing it, its all a manual process.

  • Moderators


    If you're going QML way then binding would be enough :)

  • In Qt or QML you can create flag isShift. Then in your button control you can change caption or image in depending on isShift flag.

    For example:
    DigitalButton {
    caption: isShift ? upperChar : lowerChar

    void onShiftChanged() {
    setCaption(isShift ? upperChar : lowerChar )

  • Thanks a lot for the suggestions.

    I finally achieved this using the below code:

    for (int i = 0; i < m_contentsLayout->count();i++) {
    if (QWidgetItem myItem = dynamic_cast <QWidgetItem>(m_contentsLayout->itemAt(i))) {

    QPushButton *w = dynamic_cast <QPushButton*>(myItem->widget());
    if(w != NULL)
            //qDebug()<<"Button Text:"<<w->text();
     QString str = w->text();


  • Thanks for the suggestions. I am making this completed.

  • Nevertheless, I suggest you create custom widget KeyboardButton and use signals/slots instead your loop. This approach is more flexible and extendable.

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.