我正在做Gtkmm GUI編程,我對這種編程語言很陌生。 如何讓用戶只在Gtkmm條目文本框中輸入數值。Gtkmm文本輸入過濾器
0
A
回答
0
你需要添加一個鍵釋放信號的輸入,例如這是我的條目「m_EntryAmount」
m_EntryAmount.signal_key_release_event().connect(sigc::mem_fun(*this, &Vente::entryKeyReleaseAmount));
,並添加了信號功能
bool Sales::entryKeyReleaseAmount(GdkEventKey* /* event */)
{
if(m_EntryAmount.get_text()!="" && is_number(m_EntryAmount.get_text())){
//now the Entry is not empty and its a number
//do what you want here
}else{
//here the Entry is not a number you can just delete it
m_EntryAmount.set_text("");
}
return true;
}
,並添加is_number功能
bool Vente::is_number(const string& s)
{
return !s.empty() && std::find_if(s.begin(),
s.end(), [](char c) { return !std::isdigit(c); }) == s.end();
}
這只是一個簡單的例子來說明一下,你可以自己做用你的方式
相關問題
- 1. JS過濾器文本框輸入
- 2. 過濾從文本字段中輸入
- 3. 使用jQuery過濾輸入文本
- 4. 使用輸入框過濾文本 - VBA
- 5. 輸入框過濾器宏
- 6. Android多輸入過濾器
- 7. 視頻構建過濾器的輸入和輸出過濾器?
- 8. 使用文本輸入作爲過濾器選項
- 9. Django中的HTML輸入文本框admin.py過濾器
- 10. 基於文本輸入值的ng-options過濾器
- 11. Datatables獲取過濾器文本輸入字符串
- 12. 清除輸入文本影響角度過濾器
- 13. Tensorflow + Keras + Convolution2d:ValueError:過濾器不能大於輸入:過濾器:(5,5)輸入:(3,350)
- 14. 過濾AWT文本字段輸入文本
- 15. yii2網格過濾器 - 忽略過濾器輸入變化
- 16. nodejs過濾輸入
- 17. 黑莓文本過濾器
- 18. 角度js通過文本框輸入過濾對象
- 19. 任何通過文本輸入即時過濾GridView的方式?
- 20. 本地化文本gtkmm Linux
- 21. Apigility輸入過濾注入
- 22. Java:讀取文本文件。過濾所選單詞。輸入ArrayList
- 23. VBA輸入框過濾器增強
- 24. Drupal 6輸入過濾器丟失
- 25. getline收到的過濾器輸入
- 26. jQuery Datatables bSearchable過濾器輸入值
- 27. IPython輸入前置過濾器
- 28. 十進制輸入過濾器android
- 29. 過濾器在alertDialog輸入inputText字段
- 30. 過濾器輸入字符串
你必須自己處理關鍵事件。 –