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:
{
Q_OBJECT
public:
SNOOPER
(QString sIP
);
// Constructor ~SNOOPER(); // Destructor
...
public slots:
void connectClient();
void readParts();
};
{
bool bRval = false;
if (e
->type
() == QEvent::KeyPress) {
qDebug("KeyPress event detected.");
bRval = true;
exit(0);
}
else
{
qDebug("Non-KeyPress event detected.");
}
return bRval;
}
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;
}
To copy to clipboard, switch view to plain text mode
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.
Non-KeyPress event detected.
Non-KeyPress event detected.
To copy to clipboard, switch view to plain text mode
Please let me know what I am missing.
Thanks!
Karl
Bookmarks