tailieunhanh - Rapid GUI Development with QtRuby phần 7
Tham khảo tài liệu 'rapid gui development with qtruby phần 7', ngoại ngữ, ngữ pháp tiếng anh phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | Chapter 6. Sink or Swim the Event Loop 66 2. Assuming that the default event method has not been overridden Qt Widget s event method is executed. Otherwise the custom event method is called. 3. The default event checks for any installed event filters and sends the event to the filter if installed. 4. If the event is intercepted then we re done. Otherwise event determines what type of Qt Event it s processing and converts the Qt Event into the a new class such as Qt MouseEvent . 5. The proper specialized event method then gets called in this case that s mousePressEvent . One advantage to posting events in the event loop is that repeated events such as multiple repaint requests are folded into one event. This saves processing time. The Event Loop when a new event occurs the QtRuby application does not act on it immediately. instead the event goes into a waiting queue. The mandatory Qt Application object is the keeper of this event queue. Periodically Qt Application checks this queue and dispatches the pending events to their proper places. These events are referred to as asynchronous events. This cycle of storing the events and then acting on them is referred to as the event loop. A typical QtRuby program has only one thread of execution. This means that when the Qt Application is ready to act on the queued events it must dispatch all of them to the proper objects before it can come back to handle the next batch. ideally this process happens very quickly. if however your program has some computationally intensive code such as the opening of a large file this could lead to a slowdown of the event loop processing. BOOKLEET Report erratum Chapter 6. Sink or Swim the Event Loop 67 An alternative is to use Ruby s Thread class and breakthe operation into multiple threads of control. If your application spends a large amount of time handling a certain event it may become unresponsive to other events that occur later. To a user of a GUI program this unresponsiveness is .
đang nạp các trang xem trước