Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Special Interest Groups
  3. C++ Gurus
  4. I need to get the status of Caps-lock on or off in QT framework using c++
Forum Updated to NodeBB v4.3 + New Features

I need to get the status of Caps-lock on or off in QT framework using c++

Scheduled Pinned Locked Moved Unsolved C++ Gurus
7 Posts 3 Posters 6.2k Views
  • 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.
  • M Offline
    M Offline
    MikeXing
    wrote on last edited by
    #1

    Hi All,

    I need to get the status of 'caps-lock' key is on or off in QT framework.

    Suppose if the caps-lock key is on in the keyboard before running any application. I want to read the status of caps-lock key from the keyword using QT framework.

    It would be great if someone helps me in this query.

    Thanks & Regards,

    Mike

    J.HilkJ 1 Reply Last reply
    0
    • M MikeXing

      Hi All,

      I need to get the status of 'caps-lock' key is on or off in QT framework.

      Suppose if the caps-lock key is on in the keyboard before running any application. I want to read the status of caps-lock key from the keyword using QT framework.

      It would be great if someone helps me in this query.

      Thanks & Regards,

      Mike

      J.HilkJ Offline
      J.HilkJ Offline
      J.Hilk
      Moderators
      wrote on last edited by
      #2

      @MikeXing
      you'll most likly need an OS-specific libary.

      In Windows, for example, you could go with

      "WinUser.h" include and use GetKeyState with the VK_CAPITAL key code


      Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


      Q: What's that?
      A: It's blue light.
      Q: What does it do?
      A: It turns blue.

      1 Reply Last reply
      1
      • M Offline
        M Offline
        MikeXing
        wrote on last edited by
        #3

        Thank you for your reply....
        But i want to do it in linux using QT framework.

        Regards,
        Mike

        JonBJ 1 Reply Last reply
        0
        • M MikeXing

          Thank you for your reply....
          But i want to do it in linux using QT framework.

          Regards,
          Mike

          JonBJ Online
          JonBJ Online
          JonB
          wrote on last edited by
          #4

          @MikeXing
          If @J-Hilk is right, and you can't just use Qt to determine this, have a look at http://www.qtcentre.org/threads/30180-how-to-determine-if-CapsLock-is-on-crossplatform or https://stackoverflow.com/questions/9830905/qt-4-7-4-is-there-a-way-to-find-out-the-status-of-caps-lock

          1 Reply Last reply
          2
          • M Offline
            M Offline
            MikeXing
            wrote on last edited by
            #5

            Another way is i can make forcefully set the caps-lock key to off how do i do it?

            Even though if the caps-lock key is on in the beginning of application, if i could make it forcefully to off my problem will be solved.
            So how do i forcefully make caps-lock key off?

            Regards,
            Mike

            J.HilkJ 1 Reply Last reply
            0
            • M MikeXing

              Another way is i can make forcefully set the caps-lock key to off how do i do it?

              Even though if the caps-lock key is on in the beginning of application, if i could make it forcefully to off my problem will be solved.
              So how do i forcefully make caps-lock key off?

              Regards,
              Mike

              J.HilkJ Offline
              J.HilkJ Offline
              J.Hilk
              Moderators
              wrote on last edited by
              #6

              @MikeXing
              Technically still with os specific functions.

              but in this special case you could also use an eventfilter and retranslate alle uppercase Keys into a lower case one.

              e.g: (untested)

              bool eventFilter(QObject* obj, QEvent* event)
                  {
                      if (event->type()==QEvent::KeyPress) {
                          QKeyEvent* key = static_cast<QKeyEvent*>(event);
                           Qt::KeyboardModifiers modifieres = key->modifiers();
                          modifieres.setFlag(Qt::ShiftModifier, false);
                          key->setModifiers(modifieres);
                          return QObject::eventFilter(obj,key);
                      } else {
                          return QObject::eventFilter(obj, event);
                      }
                      return false;
                  }
              

              Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


              Q: What's that?
              A: It's blue light.
              Q: What does it do?
              A: It turns blue.

              1 Reply Last reply
              0
              • M Offline
                M Offline
                MikeXing
                wrote on last edited by MikeXing
                #7
                This post is deleted!
                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