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

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.

主站蜘蛛池模板: 府谷县| 马山县| 金华市| 汉源县| 中江县| 徐汇区| 泸定县| 长宁区| 宜州市| 庐江县| 彭州市| 宿州市| 资溪县| 饶河县| 眉山市| 昔阳县| 通江县| 温泉县| 鸡东县| 铜陵市| 凯里市| 屯门区| 靖宇县| 昌邑市| 鄂尔多斯市| 鄂托克旗| 武隆县| 宕昌县| 乌鲁木齐县| 荥经县| 策勒县| 榆树市| 卢湾区| 琼中| 丁青县| 贞丰县| 金阳县| 海原县| 渭南市| 万宁市| 麦盖提县|