Is there a way to force QLineEdit to start accepting input with Hebrew as default
I have a program which is used on windows systems, running Hebrew & English as the default languages. My users are not tech savvy at all (bunch of old granpas :)). Now on each run of the program it first ask the user for a name and password - and the name must be in Hebrew (requirements are not mine). I haven't found a way to make sure the program start accepting input with Hebrew as the default so on each start they have to switch to language to Hebrew (using the OS pre-assigned key combination) and then input their user names. Since they start up the program quite of a few times each day this is bugging them.
I have tried using setLocale() to force Hebrew as the locale for the program and it works for all program defined strings, but not anywhere outside input is concerned.
So to my question, is it even possible to force QLineEdit to start accepting input with Hebrew as default?
Thanks for any answer.
Dave
Re: Is there a way to force QLineEdit to start accepting input with Hebrew as default
If I understand you correctly, you only want to have the Hebrew locale for the line edit?
If so, you can set a locale per widget:
http://doc.qt.nokia.com/4.6/qwidget.html#locale-prop
Re: Is there a way to force QLineEdit to start accepting input with Hebrew as default
I think the input method (keyboard layout) is the problem here, not the locale so the proper way would be to programatically switch the Windows keyboard layout to hebrew. In other words it's not the problem with data display (something locale is related to) but data input.
Re: Is there a way to force QLineEdit to start accepting input with Hebrew as default
Thanks for answering.
Quote:
Originally Posted by
tbscope
That's what I did. Unfortunately it doesn't affect the input language.
Re: Is there a way to force QLineEdit to start accepting input with Hebrew as default
שלו×,
I am afraid but this is OS specific since you want to change the keyboard layout. But I am sure you can change it via the system API every time the line edit gets the focus. (Or, ask the user for the shortcuts he normal uses to change the kb layout and trigger it programmatic.)
Or (not the best way) install a event handler and check for keyboard inputs and transform e.g. a "D" to "ד".
Lykurg
Re: Is there a way to force QLineEdit to start accepting input with Hebrew as default
Quote:
Originally Posted by
wysota
I think the input method (keyboard layout) is the problem here, not the locale so the proper way would be to programatically switch the Windows keyboard layout to hebrew. In other words it's not the problem with data display (something locale is related to) but data input.
That's also the conclusion Lykurg reached. I didn't think of it this way but you're both right.
Quote:
Originally Posted by
Lykurg
שלו×,
I am afraid but this is OS specific since you want to change the keyboard layout. But I am sure you can change it via the system API every time the line edit gets the focus. (Or, ask the user for the shortcuts he normal uses to change the kb layout and trigger it programmatic.)
Or (not the best way) install a event handler and check for keyboard inputs and transform e.g. a "D" to "ד".
Lykurg
×©×œ×•× ×•×‘×¨×›×” :)
I think that to trigger the key combination programmatically is the best choice. But I have no idea how to go about it. How would I trigger, for example, a shift and an alt keypress together as an input to the QLineEdit?
Thanks again
Re: Is there a way to force QLineEdit to start accepting input with Hebrew as default
since I am a fan of subclassing, I made a small example with subclassing QLineEdit, but the same could be achieved with an event filter.
Code:
{
public:
{
}
protected:
{
event->accept();
// determine which key is pressed and what hebrew letter it should be. ("switch" over event->key())
Qt::Key_unknown,
Qt::NoModifier,
}
};
Re: Is there a way to force QLineEdit to start accepting input with Hebrew as default
@Lykurg
Thanks again. That'll work perfectly.
Re: Is there a way to force QLineEdit to start accepting input with Hebrew as default
Isn't it easier to switch the keyboard layout on focusInEvent and switch it back on focusOutEvent?
Re: Is there a way to force QLineEdit to start accepting input with Hebrew as default
Sorry for being obtuse, but how do I switch the keyboard layout?
P.S in QApplication I found two function that might help: keyboardInputDirection() and keyboardInputLocale() but unfortunately they have no set equivalent.
Re: Is there a way to force QLineEdit to start accepting input with Hebrew as default
I never have done that myself and on linux it might be complicated because it depends on the graphical environment (KDE, Gnome, ...).
For windows you can have a look at http://msdn.microsoft.com/en-us/libr...=VS.85%29.aspx: ActivateKeyboardLayout, GetKeyboardLayout and GetKeyboardLayoutList.
Re: Is there a way to force QLineEdit to start accepting input with Hebrew as default
On KDE there is probably some dbus call that will do the trick.