- Qt5 C++ GUI Programming Cookbook
- Lee Zhi Eng
- 114字
- 2021-07-02 12:17:57
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.
推薦閱讀
- 腦深部電刺激術(shù)
- 急性卒中機(jī)械取栓:現(xiàn)狀與經(jīng)驗(yàn)
- 癌癥療愈錄:腫瘤門診敘事紀(jì)實(shí)
- 食品毒理學(xué)
- 超聲醫(yī)學(xué)專科能力建設(shè)專用初級(jí)教材:介入分冊(cè)
- 甲狀腺疾病的核醫(yī)學(xué)診斷與治療
- 外生殖器皮膚病及相關(guān)疾病臨床診療
- 鼻咽癌標(biāo)準(zhǔn)數(shù)據(jù)集(2023版)
- 五官科疾病中西醫(yī)結(jié)合護(hù)理
- Practical PowerShell Security and Compliance Center
- 分?jǐn)?shù)階微積分圖像修復(fù)模型在醫(yī)學(xué)CT圖像金屬偽影去除中的應(yīng)用
- 眼科護(hù)理與操作指南
- 急危重癥容量管理
- 預(yù)防老年人跌倒健康教育教程(工作人員用書)
- 新型冠狀病毒感染臨床用藥手冊(cè)