Unsolved I need to get the status of Caps-lock on or off in QT framework using c++
-
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
-
@MikeXing
you'll most likly need an OS-specific libary.In Windows, for example, you could go with
"WinUser.h"
include and useGetKeyState
with theVK_CAPITAL
key code -
Thank you for your reply....
But i want to do it in linux using QT framework.Regards,
Mike -
@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 -
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 -
@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; }
-
This post is deleted!