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 --------------------------------------------------------------------------------------------------------------------------------------------