Sumeet
Sumeet

Reputation: 8292

How Call the KeyPressEvent(QKeyEvent *) of linedit of QCombobox?

I have a QComboBox, which is editable, I implemented the keyPressEvent(QKeyEvent *) method, but it does not seem to fire this method.

I can think of the only reason this happens is that whatever editing that occurs is actually happening in lineEdit object and We should implement keyPressEvent(QKeyEvent *) of line Edit. How can I achieve this?

Upvotes: 0

Views: 418

Answers (1)

You have two options:

  1. Install an event filter on the lineEdit widget.

  2. Use setLineEdit to replace the existing widget with your own subclass that reimplements the event handler.

Upvotes: 1

Related Questions