Fix Qt inputhook

Closes gh-6804
Merge pull request #6805 from takluyver/i6804

Fix Qt inputhook with PyQt5