c++ - Disable Android keyboard in qml application -
i'm porting existing qml/c++ application android system. application running on android tablet, have issues android keyboard. since qml/c++ application has implemented own keyboard, disable android one. i've tried add android:windowsoftinputmode="statealwayshidden" line in androidmanifest.xml file, keyboard still appears when press edit box. since i'm porting existing application, not want edit code of application itself. things can edit androidmanifest.xml, qtapplication.java , qtactivity.java files. qtapplication , qtactivity derived application , activity android classes.
is possible disable android keyboard globally whole app @ startup of application(with editing manifest file or overriding oncreate, onstart or similar functions)? there functions in application , activity classes can override them , consequently disable native keyboard?
after time found solution, workaround problem. idea consume event requests software input panel (qevent::requestsoftwareinputpanel). event sent qml/c++ application host android system. so, implemented event filter called siprequesteater.
class siprequesteater: public qobject { q_object protected: bool eventfilter(qobject *obj, qevent *event) { if(event->type() == qevent::requestsoftwareinputpanel) { // filter out requestsoftwareinputpanel event return true; } else { // standard event processing return qobject::eventfilter(obj, event); } } }; this filter has installed qcoreapplication berfore qcoreapplication::run called.
qcoreapplication *coreapp = qcoreapplication::instance(); siprequesteater *siprequesteater = new siprequesteater(); coreapp->installeventfilter(siprequesteater); it can installed on qapllication.
the problem is, filter not catch qevent::requestsoftwareinputpanel event. explanation filters, installed qcoreapplication::installeventfilter(<filter>) filters input events, android qml application. qevent::requestsoftwareinputpanel going in other direction, qml application android system. didn't find out if possible filter/disable output events. because of decided filter out focus in event qevent::focusin causes qevent::requestsoftwareinputpanel.for our application works should. android keyboard not appearing anymore , our edit text fields still focus, because have our own implementation of focus , keyboard. believe not perfect solution everyone, that's why called workaround. if knows, how filter out output events, specially qevent::requestsoftwareinputpanel, please post here. final implementation of filter is:
class siprequesteater: public qobject { q_object protected: bool eventfilter(qobject *obj, qevent *event) { if(event->type() == qevent::focusin) { // filter out focusin event return true; } else { // standard event processing return qobject::eventfilter(obj, event); } } };
Comments
Post a Comment