[Qt-interest] How to catch key press/release first?
R. Reucher
rene.reucher at batcom-it.net
Fri May 15 13:55:15 CEST 2009
On Fri May 15 2009 13:38:11 Martin Gebert wrote:
> Next problem: The event filter works, but though I mark the event as
> accepted and return true from my eventFilter() the focused widget still
> handles the key press, too. What to do?
Hmmm, this doesn't happen in my case, and I don't even accept() the QEvent,
but I don't think it has to do with it...
The only _real_ difference to your code is that I use a separate class
(instantiated with a NULL parent) for the key event filter. The event filter
is not integrated with any widget class my application uses - it's just
derived from QObject.
...
...
class KeyPressFilter : public QObject
{
Q_OBJECT
public:
KeyPressFilter(QObject *parent = NULL) : QObject(parent) { ; }
protected:
bool eventFilter(QObject *, QEvent *);
};
...
...
...
...
int main(int argc, char *argv[])
{
...
QApplication myApp(argc, argv);
...
...
// setup key event filter
keyPressFilter = new KeyPressFilter();
myApp.installEventFilter(keyPressFilter);
...
...
}
Does this help in any way?
René
--
René Reucher
rene.reucher at batcom-it.net
http://www.batcom-it.net/
People who are funny and smart and return phone calls get much better
press than people who are just funny and smart.
-- Howard Simons, "The Washington Post"
More information about the Qt-interest-old
mailing list