I need to get the status of Caps-lock on or off in QT framework using c++
-
wrote on 11 Dec 2017, 07:21 last edited by
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
-
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 -
wrote on 11 Dec 2017, 08:02 last edited by
Thank you for your reply....
But i want to do it in linux using QT framework.Regards,
Mike -
Thank you for your reply....
But i want to do it in linux using QT framework.Regards,
Mikewrote on 11 Dec 2017, 11:06 last edited by@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 -
wrote on 11 Dec 2017, 13:36 last edited by
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 -
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; }
-
wrote on 12 Dec 2017, 07:23 last edited by MikeXing 12 Dec 2017, 07:26This post is deleted!
1/7