May 20, 2012

aabc aabc
Robot Herder
340 posts

QCoreApplication::sendEvent does not work with QML

 

I use QCoreApplication::sendEvent (QObject * receiver, QEvent * event) to send KeyEvent to QML TextInput.
For sone reason TextInput does not catch the event.
Anyone know why ?

9 replies

May 21, 2012

dmcr dmcr
Lab Rat
173 posts

Hello,
could you post some code please ?

 Signature 

dmcr

May 21, 2012

aabc aabc
Robot Herder
340 posts

  1. QKeyEvent keyEvent(_type,
  2.                               m_unicode,
  3.                               m_modifiers,
  4.                               QString(m_unicode),
  5.                               _autoRepeat);
  6. QApplication::sendEvent(_textInputPtr, &keyEvent);

May 21, 2012

dmcr dmcr
Lab Rat
173 posts

Well, how did you get a pointer _textInputPtr on your QML element ?
How did you connect with the Context or with DecalrativeView?

please post the complete code….

 Signature 

dmcr

May 21, 2012

aabc aabc
Robot Herder
340 posts

textInputPtr is the id of the TextInput from the QML.

I made a c++ item which inherits QWidget and used on QML (i registered it)

May 21, 2012

dmcr dmcr
Lab Rat
173 posts

You cannot use QML id in C++, that don’t make any sense.
May i ask you what kind of thing you want to achieve with your textInput?
In some case, it is quite simplier to manage things in javascript inside QML, and then send an signal to C++ when needed.

 Signature 

dmcr

May 21, 2012

aabc aabc
Robot Herder
340 posts

The qML id is a pointer to QObject.
I want to use a c++ virtual keyboard on QML

December 30, 2012

diorahman diorahman
Lab Rat
28 posts

How about sending a mouse event? e.g. https://gist.github.com/4415306

January 8, 2013

aabc aabc
Robot Herder
340 posts

But I want to send Key event

January 31, 2013

mlvljr mlvljr
Lab Rat
4 posts

At least with Qt5, one working solution seemingly is to use receiver->window()->sendEvent(),
as depicted at https://bugreports.qt-project.org/browse/QTBUG-15496 .

 
  ‹‹ Does Qt Quick Components is sutible for embedded linux or just for meego and symbian ?      Did anybody used virtual keyboard with TextInput ? ››

You must log in to post a reply. Not a member yet? Register here!