How-to override KeyPressEvent for an editable QComboBox?

谁都会走 提交于 2019-12-11 08:53:38

问题


I have a class named ValidableComboBox that derives directly from QComboBox.

Every instance of ValidableComboBox has setEditable() set to true. My goal is to add some signal that will be emitted whenever someone presses return key in the QComboBox.

To do so, I reimplemented void KeyPressEvent(QKeyEvent* e) in ValidableComboBox. However, it seems that it never gets called when I type something into the combobox.

Is there a way to achieve this ? What could possibly be wrong with what I have done ?

Thank you.


回答1:


The funktion you've seem to be using in your kode has a Kapital K, instead of a small k, ok? :-D



来源:https://stackoverflow.com/questions/3264795/how-to-override-keypressevent-for-an-editable-qcombobox

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!