TextInput and openSoftwareInputPanel on Windows
-
Hi,
is it possible to open a system virtual keyboard on a desktop? Or subclass a user custom keyboard control for this (preferred variant)? That it pops up when TextInput gets a focus? For example there is a nice keyboard in Colibri library and I can create a custom TextInput control to incorporate it in but may be there is a more generic way of doing this.
-
Looks like it was already discussed: http://developer.qt.nokia.com/forums/viewthread/1486 , http://developer.qt.nokia.com/forums/viewthread/2565
sorry...but with 'openSoftwareInputPanel' it is not so clear for me.
-
Just a short summary:
void TextInput::openSoftwareInputPanel () sends QEvent::RequestSoftwareInputPanel
void TextInput::closeSoftwareInputPanel () sends QEvent::CloseSoftwareInputPanelHandle these events to show/hide a VirtualKeyboard on QML side.
VirtualKeyboard sends keypress events calling c++ helper function:
@public slots:
Q_INVOKABLE void sendKey(const QString &key)
{
QKeyEvent event(QEvent::KeyPress, 0, Qt::NoModifier, key);
QGraphicsItem *focusItem = scene()->focusItem();
if (focusItem)
scene()->sendEvent(focusItem, &event);
}@@VirtualKeyboard {
width: 360
height: sidebar.height
rows: 4
columns: 11
keys: "ABCDEFGHIJKLMNOPQRSTUVWXYZ .-+_/0123456789"
onHideKeyboard: sidebar.show = false
onLetterClicked: mainWindow.sendKey(letter)
}@ -
And this is a version for the QtQuick2ApplicationViewer:
@const QString character;
QtQuick2ApplicationViewer *viewer;
QKeyEvent event(QEvent::KeyPress, 0, Qt::NoModifier, character);
if (viewer)
viewer->sendEvent(viewer->activeFocusItem(), &event);@