Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make a QInputDialog trigger the virtual keyboard to show up?

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

The virtual keyboard 'onboard' is used to let the user enter text. By default it is hidden. Once a text field in an application like gedit gets the focus it automatically triggers the virtual keyboard and it shows up.

However, in my application I have a QInputDialog that ask the user for some input. In my case, focusing the text field of the QInputDialog does not trigger the virtual keyboard to show up. How can I achieve that?

like image 679
Stefan Avatar asked Mar 05 '15 09:03

Stefan


People also ask

How do I add a virtual keyboard to QT?

How to build Qt Virtual Keyboard with MyScript Text SDK. The MyScript Text SDK is included in the build of Qt Virtual Keyboard by either adding CONFIG+=handwriting or CONFIG+=myscript to the qmake command line.

What is the virtual keyboard?

A virtual keyboard is software that is used to emulate a standard keyboard. A picture of a keyboard is displayed on a computer screen and the user points and clicks on the pictures of keys to enter text. Switches activated in a wide variety of ways make use of the most appropriate muscles for the individual user.


1 Answers

As per the README onboard exposes a DBUS service to allow applications to toggle's its visibility.

You probably want to do this by adding something like before and after the getText call. E.g.

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 could also use the ToggleVisible method for both calls.

This is specific to onboard, for the general showing up of any virtual keyboard solution is either integrated into QT already using the existing ibus or malitt input method engines or is done by implementing a QPlatformInputContext as demonstrated here and here or by using similar method either using DBUS or some other message passing solution (TCP sockets,etc) in order to toggle the status for that particular virtual keyboard.

like image 63
Appleman1234 Avatar answered Oct 04 '22 02:10

Appleman1234