Home  »  ArticlesGuidesHow ToTechnologyTips   »   Qt Virtual Keyboard Not Showing in Fullscreen Mode in Windows 10 Desktop?

Qt Virtual Keyboard Not Showing in Fullscreen Mode in Windows 10 Desktop?

For those familiar with Qt development, there has been a long persistent problem when it comes to dealing with the Qt virtual keyboard. For the most part, it works quite well as long as you know how to implement it in your project.

The Qt virtual keyboard is ideal for use in mobile phone and tablet apps as well as embedded systems. It is, therefore, a crucial component to have when developing Qt QML apps, There is a case for it where you do not have a physical keyboard.

The problem comes in when you do have a Desktop computer most likely a PC running Windows 10, 8.1, or Windows 7. The same can be said for rare cases in Macs or even Ubuntu systems.

Normally you wouldn’t care much about the Qt virtual keyboard because these PCs and Macs usually have physical keyboards attached to them.

Some use-cases require one to use an on-screen virtual keyboard. This would include a kiosk in a public place such as a school or shopping mall. A POS system that runs in fullscreen mode or similar systems.

The problem here is the virtual keyboard works very well when the applications are run in Window mode. In fullscreen mode, the Qt virtual keyboard tends to run behind the application window making it inaccessible.

The Qt virtual keyboard Solution

You could either go the hard way and tinker with the Qt virtual keyboard plugin source code. The good news is there is an easier way around this problem.

It involves simulating a fullscreen mode by decorating the application window in a non-conventional way.

You can start by creating your Qt Quick project using the tools provided by Qt Creator. Be sure to select the Qt virtual keyboard plugin as a component in your project.

In the main.qml file you will need to add some code to position your application window on the top-left corner of your screen.

You will also need to make the width of the application the same as the screen.

Do the same with the height but increase the height by one. This will stop the QML engine from treating it as a fullscreen window and cause the same problem to manifest.

At this point, your application window will cover the entire screen but it will still look like a traditional window. This can be fixed by removing the title bar and the buttons for closing, maximizing, and minimizing the window.

The windows decorations are removed by setting two Window flags.

Here is a sample of code showing the additionals mentioned above.

ApplicationWindow {
  id: root
  visible: true
  
  x: 0 // position window to the left of the screen
  y: 0 // position window to the top of the screen
  width: Screen.width // make window width same as screen
  height: Screen.height + 1 // make window height same as screen + 1. This prevents the window being trated as fullscreen
  flags: Qt.FramelessWindowHint | Qt.Window //first flag removes window decorations, second flag to keeps application thumbnail in the Windows taskbar.

  ...
}

There you have it. You can now use the Qt virtual keyboard in fullscreen mode in all your Desktop applications in Windows. Remember the solution above also applies to Ubuntu and other Linux flavors as well as Macs. You can find out more details about the plugin including documentation here.

Found this article interesting? Follow Brightwhiz on Facebook, Twitter, and YouTube to read and watch more content we post.

Available under:
Articles, Guides, How To, Technology, Tips