Home > Mobile >  Lambda expressions in Qt and slots
Lambda expressions in Qt and slots

Time:09-24

Recently read Qt modbus communication program, there is a groove function of writing, I don't know how to understand:
The connect (modbusDevice, & amp; QModbusDevice: : errorOccurred, [this] (QModbusDevice: : Error) {
The UI - & gt; StatusBar - & gt; ShowMessage (modbusDevice - & gt; ErrorString (), 5000);//statusBar ();
});
(parameters) : parameter list, in line with normal function argument list, if you don't need to pass parameters, can be omitted, along with parentheses (), for example, auto add=[] (int a, int b) - & gt; Int {return a + b; };
What (QModbusDevice: : Error) parameters? No variable name, the function body {
The UI - & gt; StatusBar - & gt; ShowMessage (modbusDevice - & gt; ErrorString (), 5000);//statusBar ();
} is not used, please the great god, thank you!

CodePudding user response:

QModbusDevice: : Error is sending a signal parameters, useless to can not write

CodePudding user response:

QModbusDevice: : is the Error signal parameters, Error messages, do not use can not write;
  •  Tags:  
  • Qt
  • Related