官术网_书友最值得收藏!

How it works...

In the good old days, we would typically connect a signal to a slot like this:

connect(
sender, SIGNAL(valueChanged(QString)),
receiver, SLOT(updateValue(QString))
);

However, things have changed slightly since then. In the new syntax, the SIGNAL and SLOT macros are now gone, and you must specify the type of your object, as shown in the following code:

connect(
sender, &Sender::valueChanged,
receiver, &Receiver::updateValue
);

The new syntax also allows you to connect a signal directly to a function instead of QObject:

connect(
sender, &Sender::valueChanged, myFunction
);

Additionally, you can also connect your signal to a lambda expression. We will talk more about this in the Asynchronous programming made easier recipe.

主站蜘蛛池模板: 遵义县| 湘西| 麻栗坡县| 新余市| 安溪县| 临颍县| 馆陶县| 革吉县| 镇远县| 穆棱市| 鄯善县| 神农架林区| 雅江县| 肥西县| 焦作市| 深水埗区| 惠来县| 泊头市| 洪洞县| 光泽县| 建水县| 石城县| 紫云| 永安市| 大宁县| 绩溪县| 钟山县| 阿勒泰市| 桐庐县| 寻乌县| 长兴县| 汝城县| 东莞市| 平昌县| 绿春县| 修水县| 芜湖县| 平顺县| 玛沁县| 安远县| 手游|