开发者

QT: When to use QT::keyRelease

I'm writing a test app that tests another application with a bunch of menus. I simulate keyPresses by using QT::keyPress. However, at some point it doesn't accept keyPresses anymore, until I learned you need to use keyRelease as well (according to the documentation which was a bit vague for me, it says "Note: At some point you should release the key using keyRelease()." --- but when? right after each keyPress?)

Calling a keyRelease after each keyPress simulates a keyPress as well which is weird. Calling keyRelease once after the very first call of keyPress, made the rest of the keyPresses work and the remaining keyPresses not work.

I'm confused. Can somebody tell me wh开发者_如何学Pythonen is the proper time to use keyRelease?


QTest::keyPress simulates an user pressing a key, while QTest::keyRelease simulates an user releasing a key.

After you press a key you should release it, otherwise it's like if the key is still pressed. Yes, you need to call QTest::keyRelease after any QTest::keyPress call.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜