Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.

New Contributor
Posts: 5
Registered: ‎03-28-2013
My Device: BlackBerry 10 Dev Alpha
My Carrier: none

Not getting screen events from Qt event filter

Hi -- my Qt/Cascades application is wrapping a native (OpenGL) window which wants to be able to respond to screen events on its own, so I'm installing an event filter using QAbstractEventDispatcher::instance()->setEventFilter, following the advice in <http://qt-project.org/wiki/BPS_Events_and_Qt>.


Unfortunately, while my event filter receives navigator events, it doesn't receive any screen events.  Clearly Qt is receiving screen events, since it's acting upon screen touches, but for some reason my event filter doesn't receive them.


Are screen events perhaps received on a different thread?  If so, how do I get access to that other thread to install a filter into its event dispatcher?


I'm running OS


Here's my code.  For testing, I added my filter code to main.cpp in the Cascades sample app HelloForeignWindow.


#include "helloforeignwindowapp.h"

#include <bps/bps.h>
#include <bps/screen.h>
#include <bps/navigator.h>
#include <screen/screen.h>
#include <QAbstractEventDispatcher>

using ::bb::cascades::Application;

static QAbstractEventDispatcher::EventFilter previousEventFilter = NULL;

bool EventReceived(bps_event_t* event)
	int domain = bps_event_get_domain(event);
	int code = bps_event_get_code(event);
	if (domain == screen_get_domain()) {
	    screen_event_t screen_event = screen_event_get_event(event);
	    int event_type;
	    screen_get_event_property_iv(screen_event, SCREEN_PROPERTY_TYPE, &event_type);
	    fprintf(stderr, "Screen event type %d received in filter\n", event_type);
	else if (domain == navigator_get_domain()) {
		fprintf(stderr, "Navigator event code %d received in filter\n", code);
	else {
		fprintf(stderr, "Event domain %d code %d received in filter\n", domain, code);
	return false;

static bool eventFilter(void* message)
    bps_event_t* event = (bps_event_t*)message;
    bool ret;
    ret = EventReceived(event);
    if (ret)
        return true;
    else if (previousEventFilter != NULL)
        return previousEventFilter(message);
        return false;

Q_DECL_EXPORT int main(int argc, char **argv)
    Application app(argc, argv);

    HelloForeignWindowApp mainApp;

    previousEventFilter = QAbstractEventDispatcher::instance()->setEventFilter(eventFilter);

    return Application::exec();




Posts: 74
Registered: ‎07-22-2008
My Device: BlackBerry Z10
My Carrier: N/A

Re: Not getting screen events from Qt event filter

Please take a look at the below github sample which shows how to handle touch events correctly in a Cascades foriegn window.




Pratik Sapra
Gaming & Apps Consultant
Developer Relations
New Contributor
Posts: 5
Registered: ‎03-28-2013
My Device: BlackBerry 10 Dev Alpha
My Carrier: none

Re: Not getting screen events from Qt event filter

Thanks -- that's very helpful.


Based on this code, what I'm concluding is that it's safe for the OpenGL thread to run a BPS event loop on its own screen_context_t, at the same time as QT is separately running its own event loop on a separate screen context?  That's very much not clear from the documentation.


Is it also safe for a private thread to subscribe to other BPS event types, in particular to subscribe to the same types as Qt is subscribing to?