Skip to content

Instantly share code, notes, and snippets.

@pixaline
Created February 1, 2016 20:44
Show Gist options
  • Save pixaline/46cd2889a5668f47e4ac to your computer and use it in GitHub Desktop.
Save pixaline/46cd2889a5668f47e4ac to your computer and use it in GitHub Desktop.
#include <QtCore>
#include <QApplication>
#include <QtGui>
#include <QMainWindow>
class MainWindow : public QMainWindow
{
protected:
virtual void keyReleaseEvent ( QKeyEvent * event ){
// on my systems, holding down a key for a long time will make
// it, randomly, show that it's not repeating.
// this prevents me to make functions that only work while the key is down. :(
qDebug() << event->modifiers() << event->key() << (event->key() == Qt::Key_Shift) << event->isAutoRepeat() << event->count();
}
};
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow mw;
mw.setAttribute(Qt::WA_KeyCompression, true);
mw.show();
return a.exec();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment