[PyQt] no access to protected functions or signals for objects not created from Python

Phil Thompson phil at riverbankcomputing.com
Tue Jan 25 13:23:52 GMT 2011


On Tue, 25 Jan 2011 16:10:18 +0300, disconnext <disconnexttt at gmail.com>
wrote:
> I need a main window catching all keyboard events, but with all child
> widgets (hundreds of them) working correctly. So I try:
> 
> class MainWindow(QMainWindow):
> 
>     def __init__(self, parent=None):
>         super(MainWindow, self).__init__(parent)
>         self.grabKeyboard()
>         ......
> 
>     def keyPressEvent(self, event):
>         ..........
>         self.focusWidget().keyPressEvent(event)
> 
> 
> 
> I got this error
> RuntimeError: no access to protected functions or signals for objects
> not created from Python
> 
> 
> Is there any workaround?

Install an event filter?

Phil


More information about the PyQt mailing list