pytest-qt icon indicating copy to clipboard operation
pytest-qt copied to clipboard

Clarification about methods like keyEvent, etc.?

Open Mrodent opened this issue 10 months ago • 1 comments

First, thanks for this test package, it's a life-saver.

I've been using it for some time now. I just want to simulate pressing of "Enter" on a QLineEdit (for example). There don't seem to be many examples of this kind of thing out there.

In the documentation here we see that something like keyPress or keyEvent is said to be static. (By the way that page appears to list keyPress twice, for no particular reason).

I am currently experimenting with this by going qtbot.keyEvent(...). This appears to work OK. But if that method is static, shouldn't I be using the class instead? If I try qtbot.__class__.keyEvent(...) I get this error:

AttributeError: type object 'MagicMock' has no attribute 'keyEvent'

Also, as a general rule, which should I be using, keyPress or keyEvent? Or doesn't it matter.

Mrodent avatar Apr 02 '24 06:04 Mrodent