0

I am working on an application to be deployed as a wasm app and a windows application.

we are using a windows 10 OS touch screen tablet and google chrome to access the web app. am using an empty new qt project to demonstrate the problem :

The onscreen Keyboard popups up regardless of focus meaning it will pop up wherever i touch the screen:

  • if btn is pressed
  • if lineedit is selected
  • if empty widget space is touched even though there is no focus object behind it.

i include a link to this Behaviour Video so you can see the problem.

the onscreen Keyboard popup without focus problem occurs only if i compile for webassembly, works fine on the same tablet for MSVC.

what i tried :

  1. catch the events then ignore them using :
ui->centralwidget->installEventFilter(this);
bool MainWindow::eventFilter(QObject *obj, QEvent *event)
{
//print event to qdebug 
static int eventEnumIndex = QEvent::staticMetaObject.indexOfEnumerator("Type");
 QString TEXT_Event =  QEvent::staticMetaObject.enumerator(eventEnumIndex).valueToKey(event->type());;
 qDebug()<<"TEXT EVENT="<<TEXT_Event;
 if(TEXT_Event.contains("Paint")){
//dont show print event
   }else{
     ui->Main_PlainTextEdit->appendPlainText(obj->objectName()+"=>"+TEXT_Event);
   }

 if( event->type()==QEvent::MouseButtonPress|| event->type()==QEvent::MouseButtonRelease)
  {
      // handle on-screen keyboard
      event->ignore();
      event->accept();
  }
      return true;
}
  1. setAttribute(Qt::WA_TransparentForMouseEvents);

not OK as it deactivates all mouse input => no interaction possible,

  1. setAttribute(Qt::WA_AcceptTouchEvents);

This only changes the event from Mouse event to touch event.

Maybe there is an option that i need to tick in the form editor or touchscreen option that needs to be activated, maybe the way to catch and ignore event i implemented is wrong.

I don't know what i am doing wrong but all my attempts to fix this didn't work, please help guide me ?

Thank you in advance.

1 Answers1

0

Here is how I solved it in Qt 5.15. To prevent the keyboard from popping up, I edited the default index.html. Bu default, there is a line:

<canvas id="qtcanvas" oncontextmenu="event.preventDefault()" contenteditable="true"></canvas> 

I added inputmode="none", meaning I changed it to:

<canvas id="qtcanvas" oncontextmenu="event.preventDefault()" contenteditable="true" inputmode="none"></canvas>

What this does, is it prevent the onscreen keyboard from popping up. But note that it will not popup even when a line edit is in focus, so one must use either a physical keyboard or a custom virtual keyboard widget if typing text is required in the UI.

Hopefully it will get better in future Qt versions, I see there is currently some fixes scheduled for Qt 6.4 https://bugreports.qt.io/browse/QTBUG-83064

Karmo
  • 141
  • 1
  • 7