Welcome!

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

Reply
New Contributor
EverySecond
Posts: 7
Registered: ‎12-02-2012
My Device: Playbook
My Carrier: T-mobile

Playbook + Qt: how to catch event when changing to thumbnail

[ Edited ]

Hi,

 

I'm developing applications for Playbook using Qt libraries and I'm facing up with a problem. I can't catch the event when my application is switched into thumbnail size (swipe up from the bottom) or minimized. I read many forums and I found workarounds but still not working.

 

The basic idea was that I should install an event filter for the main QT Event Dispatcher.

 

bps_initialize();
if (BPS_SUCCESS != navigator_request_events(0)) {
// This will display the log message with the source file name + index of code line
LogModule::getInstance().Display(AT, "Cannot initialize navigator requests"); } QAbstractEventDispatcher::EventFilter previousEventFilter = QAbstractEventDispatcher::instance()->setEventFilter(EventFilter); bool EventFilter(void *message) { bps_event_t * const event1 = static_cast<bps_event_t *>(message); if (event1) { LogModule::getInstance().Display(AT, "Event received"); if (event1 && bps_event_get_domain(event1) == navigator_get_domain()) { const int id = bps_event_get_code(event1); switch (id) { NAVIGATOR_SWIPE_DOWN:
LogModule::getInstance().Display(AT, "Swipe down");
break; NAVIGATOR_WINDOW_THUMBNAIL:
LogModule::getInstance().Display(AT, "Thumbnail");
break; } } }
// previousEventFilter should be handled here return false; }

With this code I can catch events like swipe down from the top, gestures, mouse clicks, timers etc. But not thumbnail resizing.

 

Overriding resizeEvent of main window is not working too, because thumbnail and minimizing will not change its size.

 

If you have any idea what I'm doing wrong or how to solve this problem it is much appreciated.

Thank you.

 

I forgot to metinoned that I know that Qt catches all the playbook events but this is not working either in the main window:

bool MainWindow::event(QEvent *event1) {
  switch (event1->type()) {
  case QEvent::Leave:
  case QEvent::WindowDeactivate:
    LogModule::getInstance().Display(AT, "Window deactivated");
    break;
  case QEvent::Enter:
  case QEvent::WindowActivate:
    LogModule::getInstance().Display(AT, "Window activated");
    break;
  default:
    break;
  }
  return false;
}

 Sometimes I receive Window Activate event, but no deactivation.

 

Please use plain text.
Developer
BGmot
Posts: 1,068
Registered: ‎11-24-2011
My Device: PlayBook
My Carrier: x

Re: Playbook + Qt: how to catch event when changing to thumbnail

I use this in your EventFilter:

    bps_event_t *activation_event = NULL;
    switch (bps_event_get_code(event)) {
...
case NAVIGATOR_WINDOW_INACTIVE: //Wait for NAVIGATOR_WINDOW_ACTIVE event for (;;) { rc = bps_get_event(&activation_event, -1); assert(rc == BPS_SUCCESS); if (bps_event_get_code(activation_event) == NAVIGATOR_WINDOW_ACTIVE) break; } break;

 

Please use plain text.
New Contributor
EverySecond
Posts: 7
Registered: ‎12-02-2012
My Device: Playbook
My Carrier: T-mobile

Re: Playbook + Qt: how to catch event when changing to thumbnail

Thank you. Now it is working.

 

The root problem was that I have used an old build from qt 4.8.1. Now I have recompiled the 4.8.3 using the "How to" and everything is working.

Please use plain text.