2

我有一个 QLineEdit,我想对用户隐藏它,但仍然在某处接受输入形式。我正在创建一个打字导师,我想以隐藏的方式接受输入,以提供更动态的反馈形式。

任何其他最好完成的建议将不胜感激

4

2 回答 2

3

You can not do it. When QLineEdit is hidden, there is no focus on it, and you can not grab events.

If you persist on using QLineEdit there's an option to turn off displaying text.QLineEdit::NoEcho.

lineEdit->setEchoMode(QLineEdit::NoEcho);

This will show the edit box, but it doesn't show any text.

Otherwise, you should write a slot to grab window keyPressed signals, and handle everything yourself.

于 2013-04-01T13:13:06.513 回答
1

对于尝试做这种事情的其他人,一种解决方法是简单地实现一个 QLineEdit 可见,但使用 MinimumSize = MaximumSize = 0x0 :)

于 2015-04-20T19:19:34.133 回答