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.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744771883a4592807.html
评论列表(0条)