Hello All,

I am new to Linux and Qt .I m trying to create a virtual keyboard in Linux using XSendEvent. The unicode characters like 'Ä', 'ä', 'Ö', 'ö', 'Ü' etc is not printed in the editor.

In windows SendInput() API is used to send the keycodes to Windows OS and "KEYEVENTF_UNICODE" flag is set for supporting unicode characters. How to support unicode characters in XSendEvent() ?

This is the code i am using to send events to OS.

// Function to create a keyboard event
XKeyEvent createKeyEvent(Display *display, Window &win,
Window &winRoot, bool press,
int keycode, int modifiers)
XKeyEvent event;

event.display = display;
event.window = win;
event.root = winRoot;
event.subwindow = None;
event.time = CurrentTime;
event.x = 1;
event.y = 1;
event.x_root = 1;
event.y_root = 1;
event.same_screen = True;
event.keycode = XKeysymToKeycode(display, keycode);
event.state = modifiers;

event.type = KeyPress;
event.type = KeyRelease;

return event;

Void SendInput(int a_nVirtualKeyCode )
// Obtain the X11 display.
Display *display = XOpenDisplay(0);
if(display == NULL)
return ;

// Get the root window for the current display.
Window winRoot = XDefaultRootWindow(display);

// Find the window which has the current keyboard focus.
Window winFocus;
int revert;
XGetInputFocus(display, &winFocus, &revert);

// Send a fake key press event to the window.
XKeyEvent event = createKeyEvent(display, winFocus, winRoot, true, a_nVirtualKeyCode, 0);
XSendEvent(event.display, event.window, True, KeyPressMask, (XEvent *)&event);

// Send a fake key release event to the window.
event = createKeyEvent(display, winFocus, winRoot, false, a_nVirtualKeyCode, 0);
XSendEvent(event.display, event.window, True, KeyPressMask, (XEvent *)&event);

// Done.

Thanks in advance