admin管理员组文章数量:1391733
I tried to override the keyReleaseEvent
function, but it causes a loop call due to the automatic repetition when holding down a key, and using isAutoRepeat
doesn't work (on Linux X11), as it always returns false
.
Reproduce code (Linux X11 only):
#include <QApplication>
#include <QDebug>
#include <QKeyEvent>
#include <QWidget>
class Window : public QWidget {
public:
Window(QWidget* parent = nullptr): QWidget(parent) {}
void keyReleaseEvent(QKeyEvent* event) override {
if (!event->isAutoRepeat())//Normal on Windows
qDebug() << "keyRelease";
}
};
int main(int argc, char** argv) {
QApplication app(argc,argv);
Window window;
window.show();
return app.exec();
}
Currently, I believe the reason is as mentioned in the documentation:
Note that if the event is a multiple-key compressed event that is partly due to auto-repeat, this function could return either true or false indeterminately.
本文标签: cHow to determine if a key has truly been released in QtStack Overflow
版权声明:本文标题:c++ - How to determine if a key has truly been released in Qt? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744771882a2624387.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论