The mouse event shows how QT/Embedded form events are distributed.

Source: Internet
Author: User

Qt's form system can contain multiple processes. For Linux applications, a process can correspond to one application, and each application has its own mainwindow, you can also have your own widget stack .. Assume that multiple applications are opened at the same time, and Windows does not completely overwrite each application. When we click the form of an application, the form of this application appears at the top of the screen. It is not difficult to understand Windows Forms servers. A process similar to Windows xp x-Windows sever may be used to manage the mouse, keyboard, and LCD display. I was the first to contact the GUI of a smartphone. The form management of a non-smartphone is relatively simple. Taking a mobile phone platform I used as an example, there is only one dialog stack on a mobile phone, consider this stack as a zcoordinate, and the bottom of the stack is located at the coordinate origin, the full screen is displayed from the top of the stack, and the windows that are not fully covered are located down the zcoordinate until the screen data is fully filled, key events are transmitted to ui_task (ui_task is responsible for initializing other applications, and all windows events are distributed by the dialostack application ). How does QT manage the form when returning to the positive volume? The following details.

 

QapplicationHow to obtainMouse event?

Check the qapplication Code. There is a guisever application. What is the difference between a guiserver application and other applications? The biggest difference is thatQt_initInitialize function callQwsserver: startupThis application creates a form server. InQwsserverIn the constructor:

 Opendisplay ();//Initialize display and screen parameters to enable LCD.

Openmouse ();//Turn on the mouse Device

Openkeyboard ();// Enable the keyboard Device

Openmouse (): qwsmousehandler * H = newmousehandler (MS) Open the mouse device, after opening the mouse device, listen to the open mouse device file descriptor through the qsocketnotifier interface, in the qwsmousehandler constructor, setmousehandler is called to establish the communication between the window server and the mouse device: In the qwsserver, connected signal (mousechanged) and slot (setmouse) (Currently, this platform is different from the new QT Development Kit. In the qt-embedded-free-3.3.6, the mouse communicates with the Windows Server by directly calling qwsserver: sendmouseevent in qmouse_ws.cpp ). Now we can get the mouse data. The form to which the data will be passed. In sendmouseevent, the window is called. at (POS) searches for the top-level windows of all Windows applications stored in this linked list (top-level forms refer to forms without parent or style: wtype_toplevel) the request response area contains the format (requested-region: the area displayed by the form) with the mouse coordinates. Once the data is found, it is passed to this form (the message is placed in the incoming message queue of qapplication, the qapplication is responsible for distributing the message) and then transmits the message to the Message Queue of the corresponding application through the client socket.

  Windows list How to create ?When creating each qwidget object, the system calls the qwidget: Create Function, if the qwidget we created is top-level, a message will be sent to qwssever and a globalwinowsid will be created here (see get_object_id () call in qwsserver ), if the qwidget is a child widget, A locawindowslid is created in this application (see takelocalid (). No matter where the winodwsid is created, qwidget is used in each independent application:: setwinid is saved. The difference between globalwindows and localwindows is that the globalwindowsid created in qwsserver is used for global qapp, that is, buttons, mouse, and other events are passed to the corresponding application through qwssever. Press the key and mouse events are processed in the focus widget of the qapp that obtains these events. These focus widgets can be globalwindows or localwindows. Before this window is show, we only get windowsid. When the window is displayed, in qwsserver, create a qwswindow object based on globalwindowsid and save the object to the Windows list of qwsserver. Qapplication Medium Mouse event Transfer and Processing When the application's message queue is not empty, processevents is called to process the message queue. If the application does not have a mode dialog box and there is no widget bound to the mouse event, traverse globalwindow in the application (for the user, the form where the mouse is located) all the child qwidget objects of the corresponding widget, that is, the Child widget first looks for the widget that responds to the mouse event. If the window is not overwritten by a window with a higher priority, the raise function is called to adjust the form to the top layer of the Windows list.

QwsseverAndApplicationEstablish communication Pipelines

Qt supports multiple processes.EmbeddedFor devices, an independent guiserver application exists. This application acts as a server and other applications act as clients. The connection between the server and the client is completed during application initialization.

Server:

The server application process callsQwsserver: startupComplete server creation.

Client:

Application calls qwsdisplaydata: init to create a qwssocket object and establishes a connection with the server through connecttolocalfile.

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.