Hi!
I'm running a simple command line application based on QCoreApplication and for some reason I am not receiving keyboard inputs. When in run this program in the command line on Linux using ./Application, I can see the keys that I press on the keyboard and but there is no reaction from the keyPressEvent. Can anyone point out where my mistake is?
int main(int argc, char *argv[])
{
Application w;
a.installEventFilter(&w);
return a.exec();
}
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
Application w;
a.installEventFilter(&w);
return a.exec();
}
To copy to clipboard, switch view to plain text mode
{
Q_OBJECT
public:
~Application();
protected:
};
void Application
::keyPressEvent(QKeyEvent *event
) {
qDebug() << "keyPressEvent event occured" << event; // This is never printed.
}
class Application : public QObject
{
Q_OBJECT
public:
Application(QObject *parent = 0);
~Application();
protected:
void keyPressEvent(QKeyEvent *event);
};
void Application::keyPressEvent(QKeyEvent *event)
{
qDebug() << "keyPressEvent event occured" << event; // This is never printed.
}
To copy to clipboard, switch view to plain text mode
Bookmarks