How to create a QInputDialog to launch a virtual keyboard?

I am developing a Qt application with Python and PySide. The application runs on Ubuntu Linux; The machine has a touch screen.

The onboard virtual keyboard is used to allow the user to enter text. By default, it is hidden. When a text field in an application such as gedit gains focus, it automatically launches a virtual keyboard and appears.

However, in my application, I have a QInputDialog that asks the user for some input. In my case, focusing the QInputDialog text field does not cause the virtual keyboard to appear. How can i achieve this?

+5
source share
1 answer

In accordance with README , the DBUS service is opened on board, allowing applications to switch to its visibility.

You might want to do this by adding something like before and after calling getText. For instance.

msg = QtDBus.QDBusMessage.createMethodCall('org.onboard.Onboard', '/org/onboard/Onboard/Keyboard','org.onboard.Onboard.Keyboard' 'org.onboard.Onboard.Keyboard.Show') QtDBus.QDBusConnection.sessionBus().send(msg) text, ok = QtGui.QInputDialog.getText(self, 'Input Dialog', 'Enter your name:') msg2 = QtDBus.QDBusMessage.createMethodCall('org.onboard.Onboard', '/org/onboard/Onboard/Keyboard','org.onboard.Onboard.Keyboard' 'org.onboard.Onboard.Keyboard.Hide') QtDBus.QDBusConnection.sessionBus().send(msg2) 

You can also use the ToggleVisible method for both calls.

This is specific to onboard, since the general mapping of any virtual keyboard solution is either integrated into QT already using the existing ibus or malitt I / O mechanisms, or is done by implementing the QPlatformInputContext, as shown here and here, or using a similar method, either using DBUS or some other messaging solution (TCP sockets, etc.) to switch the status for this virtual keyboard.

+3
source

Source: https://habr.com/ru/post/1214722/


All Articles