Interception and processing of QT for Symbian frontend/backend switch events

Source: Internet
Author: User

A function is required in the project: when the program is switched to the background, the tray representing the program must be displayed on the desktop of the mobile phone. When the program is switched to the foreground, the tray is hidden. To achieve this, you must first intercept the program's frontend and backend switchover events. I wrote a blog post to solve this problem, but it is not easy to use. Here is the final solution.

First, QT itself cannot implement this across platforms. We can only customize different methods for different platforms. Under QT for Symbian: There is a symbianeventfilter () Event Filter, which can intercept all Symbian events, including the frontend and backend switching events. The Code is as follows:

# Ifdef q_ OS _symbian <br/> bool cqqapplication: symbianeventfilter (const qsymbianevent * event) <br/>{< br/> const twsevent * pwsevent = event-> windowserverevent (); </P> <p> If (pwsevent = NULL) <br/>{< br/> return false; <br/>}</P> <p> If (eeventfocuslost = pwsevent-> type ()) // switch to the background <br/>{< br/> emit signal_foreground (false); <br/> return false; <br/>}< br/> else if (eeventfocusgained = pwsevent-> type ()) // switch to the foreground <br/>{< br/> emit signal_foreground (true); <br/> return false; <br/>}< br/> else <br/>{< br/> return false; // handed over to the system for processing <br/>}< br/> # endif 

The implementation steps are as follows:

 

1: Inherit from qapplication to implement a new custom application class.

2: implement the symbianeventfilter () virtual function to process the eeventfocuslost and eeventfocusgained events.

3: Return false after the two events are processed, so that the system can continue to process them.

 

My practice is as shown in the code above: I usually send a signal to process it elsewhere.

 

Certificate --------------------------------------------------------------------------------------------------------------------------------------------

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.