Re: QDialog keypress event
Quote:
What do I need to capture any key that is pressed in this Dialog?
Simply reimplement QDialog::keyPressEvent.
Re: QDialog keypress event
Actually I figured out the problem, but I am not sure how to fix it. I have a QTableView on the form. It is catching keystrokes first. I disabled the QTableView, then my keyPressEvent works. Can I disable the QTableView processing of keypresses and implement them in my form?
Re: QDialog keypress event
You can install an event filter on the treeview and only let events pass that you don't need to handle yourself.
Cheers,
_
Re: QDialog keypress event
I added a call to the grabKeyboard() method in the constructor, then when the proper key is pressed to close the form, I added releaseKeyBoard(). I realize I may have to handle the navigation in the table view, but that is Ok.
Re: QDialog keypress event
Quote:
I added a call to the grabKeyboard()
That seems a rather extreme solution when simply adding an event filter to the table view would do it. Any time you grab control of an input device, there is always the chance that some corner case will lead to a condition where your app is locked up and there is no way to get back to the widget that has grabbed the inputs.
Quote:
I realize I may have to handle the navigation in the table view
Which is exactly what the event filter would let you easily do - as anda_skoa said, you let events pass that you don't need to handle yourself.
Re: QDialog keypress event
Quote:
Originally Posted by
d_stranz
Which is exactly what the event filter would let you easily do - you let events pass that you don't need to handle yourself.
Or even let all events pass, if you just need to use the filter as a means to act on some event(s) before the target widget does.