Results 1 to 5 of 5

Thread: Can't filter native events on Android

  1. #1
    Join Date
    Jun 2010
    Posts
    22
    Qt products
    Qt4
    Platforms
    Windows

    Default Can't filter native events on Android

    Is it possible to use the QAbstractNativeEventFilter on Android yet? I've tried subclassing it and reimplementing the nativeEventFilter function, but it is never called. The same code does work on Windows though. I need this functionality to pass events on to a 3rd-party input library for a game engine that I'm working on. Any input is much appreciated.


    Thanks!

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Can't filter native events on Android

    All the UI events on Android are Java interface method calls (callbacks) and get translated in Qt/C++ events inside the Qt platform adapter plugin.
    Which then sends them directly to the window in questions.

    The event dispatcher only sees native Unix events, e.g. for sockets or timers.

    Just to clarify: you need the native events, i.e. the Java event objects because the engine is written in Java?

    Cheers,
    _

  3. #3
    Join Date
    Jun 2010
    Posts
    22
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Can't filter native events on Android

    Quote Originally Posted by anda_skoa View Post
    All the UI events on Android are Java interface method calls (callbacks) and get translated in Qt/C++ events inside the Qt platform adapter plugin.
    Which then sends them directly to the window in questions.

    The event dispatcher only sees native Unix events, e.g. for sockets or timers.

    Just to clarify: you need the native events, i.e. the Java event objects because the engine is written in Java?

    Cheers,
    _
    The native events is what I need (touch and motion events) from the java side of things. The engine is being written in C++ though, so I'm not sure how to set the callback functions properly, or how to even access them from Qt.

    Here is how it is achieved using native android without Qt:
    https://github.com/jkuhlmann/gainput...le_android.cpp

    I must admit that I'm relatively new to programming Qt on Android and Android development in general, but so far this has been the only snag.

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Can't filter native events on Android

    If you can transform from Java objects to C++, why not convert the Qt event objects to the target C++ objects instead?

    I.e. the Qt platform plugin transforms the Java events to Qt events and passes them to the window. You then convert the Qt event to engine event and pass that to the engine.

    Cheers,
    _

  5. #5
    Join Date
    Jun 2010
    Posts
    22
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Can't filter native events on Android

    Quote Originally Posted by anda_skoa View Post
    If you can transform from Java objects to C++, why not convert the Qt event objects to the target C++ objects instead?

    I.e. the Qt platform plugin transforms the Java events to Qt events and passes them to the window. You then convert the Qt event to engine event and pass that to the engine.

    Cheers,
    _
    Well, I got it to work by just modifying the input library to use Qt events directly since the Qt event provides the same information.

Similar Threads

  1. Replies: 4
    Last Post: 10th July 2014, 15:22
  2. How do you make android applications display correctly on android phone?
    By Cyrebo in forum Qt for Embedded and Mobile
    Replies: 1
    Last Post: 17th August 2013, 07:31
  3. QTableWidget + QEventFilter: cannot filter mouse events
    By trallallero in forum Qt Programming
    Replies: 2
    Last Post: 8th October 2011, 08:16
  4. Event filter with mouse events
    By felo188 in forum Qt Programming
    Replies: 13
    Last Post: 22nd July 2011, 10:57
  5. Replies: 2
    Last Post: 12th October 2008, 01:55

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.