KaptainKarl
18th December 2008, 17:29
QT Version: 4.4.1
OS: RHEL 5
I am attempting to create a console application that uses QLocalServer/QLocalSocket for interprocess communication.
In the program, I stay in the event loop waiting for connections.
If the user presses a key, I want to exit the program.
I have remplemented the eventFilter method and added a installEventFilter(this) call to the constructor of the SNOOPER class:
class SNOOPER: public QObject
{
Q_OBJECT
public:
SNOOPER(QString sIP); // Constructor
~SNOOPER(); // Destructor
...
bool eventFilter( QObject *o, QEvent *e );
public slots:
void connectClient();
void readParts();
};
bool SNOOPER::eventFilter( QObject *o, QEvent *e )
{
bool bRval = false;
if (e->type() == QEvent::KeyPress)
{
qDebug("KeyPress event detected.");
bRval = true;
exit(0);
}
else
{
qDebug("Non-KeyPress event detected.");
}
return bRval;
}I received the following output when I run the program, but I do not get any key events:
Non-KeyPress event detected.
Non-KeyPress event detected.Please let me know what I am missing.
Thanks!
Karl
OS: RHEL 5
I am attempting to create a console application that uses QLocalServer/QLocalSocket for interprocess communication.
In the program, I stay in the event loop waiting for connections.
If the user presses a key, I want to exit the program.
I have remplemented the eventFilter method and added a installEventFilter(this) call to the constructor of the SNOOPER class:
class SNOOPER: public QObject
{
Q_OBJECT
public:
SNOOPER(QString sIP); // Constructor
~SNOOPER(); // Destructor
...
bool eventFilter( QObject *o, QEvent *e );
public slots:
void connectClient();
void readParts();
};
bool SNOOPER::eventFilter( QObject *o, QEvent *e )
{
bool bRval = false;
if (e->type() == QEvent::KeyPress)
{
qDebug("KeyPress event detected.");
bRval = true;
exit(0);
}
else
{
qDebug("Non-KeyPress event detected.");
}
return bRval;
}I received the following output when I run the program, but I do not get any key events:
Non-KeyPress event detected.
Non-KeyPress event detected.Please let me know what I am missing.
Thanks!
Karl