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

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.

主站蜘蛛池模板: 富川| 库伦旗| 四平市| 景东| 饶阳县| 启东市| 襄樊市| 东兰县| 尚义县| 辽宁省| 鲜城| 灯塔市| 淄博市| 青神县| 万州区| 远安县| 莲花县| 万荣县| 贡山| 阳山县| 云阳县| 淮阳县| 黄浦区| 库车县| 吴堡县| 嘉禾县| 龙海市| 南川市| 平凉市| 虹口区| 乐业县| 佛学| 淮南市| 渝中区| 平阳县| 周宁县| 凤冈县| 疏附县| 肥东县| 揭东县| 新丰县|