I have both events for those keys (Qt 4.7.2 + windows 7). Here is my code:
#include <QApplication>
#include <QtGui>
{
protected:
virtual void keyPressEvent
(QKeyEvent * event
);
virtual void keyReleaseEvent
(QKeyEvent * event
);
};
{
qDebug() << "key pressed";
}
{
qDebug() << "key released";
}
int main(int argc, char * argv[])
{
MyWindow w;
w.show();
return a.exec();
}
#include <QApplication>
#include <QtGui>
class MyWindow: public QMainWindow
{
protected:
virtual void keyPressEvent(QKeyEvent * event);
virtual void keyReleaseEvent(QKeyEvent * event);
};
void MyWindow::keyPressEvent(QKeyEvent *)
{
qDebug() << "key pressed";
}
void MyWindow::keyReleaseEvent(QKeyEvent *)
{
qDebug() << "key released";
}
int main(int argc, char * argv[])
{
QApplication a(argc, argv);
MyWindow w;
w.show();
return a.exec();
}
To copy to clipboard, switch view to plain text mode
make sure you have your widget focused.
Bookmarks