freepeople性欧美熟妇, 色戒完整版无删减158分钟hd, 无码精品国产vα在线观看DVD, 丰满少妇伦精品无码专区在线观看,艾栗栗与纹身男宾馆3p50分钟,国产AV片在线观看,黑人与美女高潮,18岁女RAPPERDISSSUBS,国产手机在机看影片

正文內容

qt的對象模型與信號槽的概念-資料下載頁

2025-02-23 00:22本頁面
  

【正文】 TempConverter setTempCelsius setTempFahrenheit tempCelsiusChanged tempFahrenheitChanged valueChanged → setTempCelsius valueChanged → setTempFahrenheit tempCelsiusChanged → setValue tempFahrenheitChanged → setValue valueChanged → display connect(celsiusDial, SIGNAL(valueChanged(int)), tempConverter, SLOT(setTempCelsius(int)))。 connect(celsiusDial, SIGNAL(valueChanged(int)), celsiusLcd, SLOT(display(int)))。 connect(tempConverter, SIGNAL(tempCelsiusChanged(int)), celsiusDial, SLOT(setValue(int)))。 connect(fahrenheitDial, SIGNAL(valueChanged(int)), tempConverter, SLOT(setTempFahrenheit(int)))。 connect(fahrenheitDial, SIGNAL(valueChanged(int)), fahrenheitLcd, SLOT(display(int)))。 connect(tempConverter, SIGNAL(tempFahrenheitChanged(int)), fahrenheitDial, SLOT(setValue(int)))。 溫度轉換器 ? 用戶調節(jié)攝氏度表盤。 TempConverter setTempCelsius setTempFahrenheit tempCelsiusChanged tempFahrenheitChanged valueChanged → setTempCelsius valueChanged → setTempFahrenheit tempCelsiusChanged → setValue tempFahrenheitChanged → setValue valueChanged → display connect(celsiusDial, SIGNAL(valueChanged(int)), tempConverter, SLOT(setTempCelsius(int)))。 connect(celsiusDial, SIGNAL(valueChanged(int)), celsiusLcd, SLOT(display(int)))。 connect(tempConverter, SIGNAL(tempCelsiusChanged(int)), celsiusDial, SLOT(setValue(int)))。 connect(fahrenheitDial, SIGNAL(valueChanged(int)), tempConverter, SLOT(setTempFahrenheit(int)))。 connect(fahrenheitDial, SIGNAL(valueChanged(int)), fahrenheitLcd, SLOT(display(int)))。 connect(tempConverter, SIGNAL(tempFahrenheitChanged(int)), fahrenheitDial, SLOT(setValue(int)))。 溫度轉換器 ? 用戶調節(jié)攝氏度表盤。 TempConverter setTempCelsius setTempFahrenheit tempCelsiusChanged tempFahrenheitChanged valueChanged → setTempCelsius valueChanged → setTempFahrenheit tempCelsiusChanged → setValue tempFahrenheitChanged → setValue valueChanged → display connect(celsiusDial, SIGNAL(valueChanged(int)), tempConverter, SLOT(setTempCelsius(int)))。 connect(celsiusDial, SIGNAL(valueChanged(int)), celsiusLcd, SLOT(display(int)))。 connect(tempConverter, SIGNAL(tempCelsiusChanged(int)), celsiusDial, SLOT(setValue(int)))。 connect(fahrenheitDial, SIGNAL(valueChanged(int)), tempConverter, SLOT(setTempFahrenheit(int)))。 connect(fahrenheitDial, SIGNAL(valueChanged(int)), fahrenheitLcd, SLOT(display(int)))。 connect(tempConverter, SIGNAL(tempFahrenheitChanged(int)), fahrenheitDial, SLOT(setValue(int)))。 與值關聯(lián) ? ? 一種常見情況是,希望在關聯(lián)聲明中傳遞一個值。 ? 例如 , 鍵盤實例 ? 這不是有效的 它將不會關聯(lián)。 connect(key, SIGNAL(clicked()), this, SLOT(keyPressed(1)))。 與值關聯(lián) ? ? 解決方法 1: 多個槽 { ... public slots: void key1Pressed()。 void key2Pressed()。 void key3Pressed()。 void key4Pressed()。 void key5Pressed()。 void key6Pressed()。 void key7Pressed()。 void key8Pressed()。 void key9Pressed()。 void key0Pressed()。 ... } connections 與值關聯(lián) ? ? 解決方法 2: 子類發(fā)射器和增加信號 QPushButton QIntPushButton { ... signals: void clicked(int)。 ... } { QIntPushButton *b。 b=new QIntPushButton(1)。 connect(b, SIGNAL(clicked(int)), this, SLOT(keyPressed(int)))。 b=new QIntPushButton(2)。 connect(b, SIGNAL(clicked(int)), this, SLOT(keyPressed(int)))。 b=new QIntPushButton(3)。 connect(b, SIGNAL(clicked(int)), this, SLOT(keyPressed(int)))。 ... } 解決方案評價 ? 1: 多個槽 ? 許多槽包含幾乎相同的代碼 ? 難于維護 (一個小的變化影響所有槽 ) ? 難于擴展 (每次都要新建槽 ) ? 2:子類發(fā)射器和增加信號 ? 額外的專用類 (難于重用 ) ? 難于擴展 (每個情況需新建子類 ) 信號映射器 ? QSignalMapper 類解決了這個問題 ? 將每個值映射到每個發(fā)射器 ? 介于可重用類之間 { QSignalMapper *m = QSignalMapper(this)。 QPushButton *b。 b=new QPushButton(1)。 connect(b, SIGNAL(clicked()), m, SLOT(map()))。 msetMapping(b, 1)。 ... connect(m, SIGNAL(mapped(int)), this, SLOT(keyPressed(int)))。 } 創(chuàng)建一個信號映射器 關聯(lián)按鈕到映射器 關聯(lián)一個發(fā)射器和一個值。 關聯(lián)映射器到槽上。 信號映射器 QSignalMapper { ... public slots: void keyPressed()。 ... } connections connection ? 信號映射器把每一個按鈕和值關聯(lián)起來。這些值都被映射。 ? 當一個值被映射,映射器發(fā)出攜帶關聯(lián)的值的映射信號( int)。 演講完畢,謝謝觀看!
點擊復制文檔內容
環(huán)評公示相關推薦
文庫吧 www.dybbs8.com
備案圖鄂ICP備17016276號-1