Qt 1.5 learn basic signals and slots

Disclaimer: This article is a blogger original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.
This link: https://blog.csdn.net/qhs414/article/details/102768276

Signals and slots    

Qt defined concepts associated with the system messages

  • Signal (Signal): messages generated by the operating system
  • Slot (Slot): program message handling functions connected
  • (Connect): binding system message to the message handler      

Qt message handling mechanism in

                                                                                                                                                                                                                                 

   The core -QObject Qt :: connect function

bool connect(const QObject* sender,         //发送对象
             const char* signal,            //消息名
             const QObject* receiver,       //接受对象
             const char* method,            //接受对象额成员函数
             Qt::ConnectionType type = Qt ::AutoConnection);

 In Qt, the message string is described

connect function establishes a mapping between the names and message handlers

  1. SIGNAL: used to specify the message name
  2. SLOT: specifies the name of the message processing function
  3. Q_OBJECT: All custom class slots must be added Q_OBJRCT at the beginning of the class declaration
  4. slots: a class declaration for message processing function 

    Custom tank:  

  • Only QObject word to the custom class slots
  • Slot class definition must be used at the beginning of the most Q_OBJECT declared
  • You need to use the keyword class slots declared in the slot
  • Groove signal must be processed in the same function signature
  • SIGNAL and SLOT specified name: parameters can include type specific parameter name can not contain

                                                                                                                                                                                                                                        

Guess you like

Origin blog.csdn.net/qhs414/article/details/102768276