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
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
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.
dave (11th July 2010)
שלו×,
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
dave (11th July 2010)
That's also the conclusion Lykurg reached. I didn't think of it this way but you're both right.
×©×œ×•× ×•×‘×¨×›×”
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
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.
Qt 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, } };To copy to clipboard, switch view to plain text mode
@Lykurg
Thanks again. That'll work perfectly.
Isn't it easier to switch the keyboard layout on focusInEvent and switch it back on focusOutEvent?
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.
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.
On KDE there is probably some dbus call that will do the trick.
Bookmarks