问题描述
我有一个名为ValidableComboBox
的类,直接从QComboBox
派生.
I have a class named ValidableComboBox
that derives directly from QComboBox
.
每个ValidableComboBox
实例都将setEditable()
设置为true
.我的目标是添加一些信号,只要有人按下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
.
为此,我在ValidableComboBox
中重新实现了void KeyPressEvent(QKeyEvent* e)
.但是,当我在组合框中键入内容时,似乎永远都不会调用它.
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 ?
谢谢.
推荐答案
您似乎在kode中使用的功能具有Kapital K,而不是小k,好吗? :-D
The funktion you've seem to be using in your kode has a Kapital K, instead of a small k, ok? :-D
这篇关于如何为可编辑的QComboBox覆盖KeyPressEvent?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!