Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [Solved] Software Keyboard in QT
Forum Updated to NodeBB v4.3 + New Features

[Solved] Software Keyboard in QT

Scheduled Pinned Locked Moved General and Desktop
7 Posts 4 Posters 1.6k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Sidii
    wrote on last edited by
    #1

    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.

    Thanks
    Sid

    1 Reply Last reply
    0
    • Pradeep P NP Offline
      Pradeep P NP Offline
      Pradeep P N
      wrote on last edited by
      #2

      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.

      Pradeep Nimbalkar.
      Upvote the answer(s) that helped you to solve the issue...
      Keep code clean.

      1 Reply Last reply
      2
      • p3c0P Offline
        p3c0P Offline
        p3c0
        Moderators
        wrote on last edited by
        #3

        Hi,

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

        157

        1 Reply Last reply
        0
        • I Offline
          I Offline
          Ildar
          wrote on last edited by
          #4

          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:
          QML
          @
          DigitalButton {
          caption: isShift ? upperChar : lowerChar
          ...
          }@

          Qt:
          @
          slots:
          void onShiftChanged() {
          setCaption(isShift ? upperChar : lowerChar )
          }
          @

          1 Reply Last reply
          0
          • S Offline
            S Offline
            Sidii
            wrote on last edited by
            #5

            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();
             if(m_bPressedCapsLock)
              w->setText(str.toUpper());
             else
              w->setText(str.toLower());
            }
                                }}
            

            @

            1 Reply Last reply
            0
            • S Offline
              S Offline
              Sidii
              wrote on last edited by
              #6

              Thanks for the suggestions. I am making this completed.

              1 Reply Last reply
              0
              • I Offline
                I Offline
                Ildar
                wrote on last edited by
                #7

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

                1 Reply Last reply
                0

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved