[Qt] postevent emit----event and signal__signal

Source: Internet
Author: User
Tags emit



Signal sent by: emit
How the event is sent:
1: Window System events;
(The values listed in Qevent::type are best defined as values greater than 5000, such as: const Qevent::type Customevent_login = (qevent::type) 5001;)
2: Manually sent by Sendevent ()/postevent ();
(I prefer to use postevent, submission method, when processing to QT system decision, the way is mild, not easy to make mistakes; Sendevent is submitted, it has to be dealt with immediately, as if the concept of error is larger, more difficult to operate. )
The relationship between event and signal: There is no inevitable relationship between the two. When an event occurs, emit is sometimes invoked to send a signal in a handler function.
BOOL Qobject::event (qevent *e)
{
#if defined (check_null)
if (E = = 0)
Qwarning ("Qobject::event:null events are not permitted");
#endif
if (eventfilters) {//try Filters
if (Activate_filters (e))//stopped by a filter
return TRUE;
}
Switch (E->type ()) {
Case Qevent::timer:
TimerEvent ((qtimerevent*) e);
Returntrue;
Case qevent::childinserted:
Case qevent::childremoved:
Childevent ((qchildevent*) e);
Returntrue;
Default
Break
}
Returnfalse;
}

Qobject::event () was implemented in Qwidget, and the handling of the event became more complete.
BOOL Qwidget::event (qevent *e)
{
if (Qobject::event (e))
return TRUE;

Switch (E->type ()) {
Case Qevent::mousemove:
Mousemoveevent ((qmouseevent*) e);
Break

Case Qevent::mousebuttonpress:
Mousepressevent ((qmouseevent*) e);
Break

Case Qevent::mousebuttonrelease:
Mousereleaseevent ((qmouseevent*) e);
Break

Case Qevent::mousebuttondblclick:
Mousedoubleclickevent ((qmouseevent*) e);
Break

Case Qevent::wheel:
Wheelevent ((qwheelevent*) e);
if (! ((qwheelevent*) e)->isaccepted ())
return FALSE;
Break
Case Qevent::keypress: {
Qkeyevent *k = (qkeyevent *) e;
bool res = FALSE;
if (k->key () = = Key_backtab | |
(K->key () = Key_tab &&
(K->state () & Shiftbutton)) ) {
Qfocusevent::setreason (Qfocusevent::tab);
res = Focusnextprevchild (FALSE);
Qfocusevent::resetreason ();

else if (k->key () = = Key_tab) {
Qfocusevent::setreason (Qfocusevent::tab);
res = Focusnextprevchild (TRUE);
Qfocusevent::resetreason ();
}
if (res)
Break
Qwidget *w = this;
while (W) {
W->keypressevent (k);
if (k->isaccepted () | | w->istoplevel ())

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.