First of all - Thanks for the idea! Seems to be exactly what I was looking for (since it took 2 lines of code to implement)
{
if(qwOld)qwOld->removeEventFilter(this);
if(qwNew) qwNew->installEventFilter(this);
}
void MainWindow::FocusChanged(QWidget * qwOld, QWidget* qwNew)
{
if(qwOld)qwOld->removeEventFilter(this);
if(qwNew) qwNew->installEventFilter(this);
}
To copy to clipboard, switch view to plain text mode
Well it could use a check if the user is in this exact window, but thats details (never would have thought of looking for focus change signal on the qApp lvl though ...). My problem with listening on all possible widgets was that proper propagation of events is not as easy to implement (therefore I could miss/duplicate a keypress if I get it wrong).
As for the reason (in case it matters) - the project is a Pos for shops/supermarkets. Most of the competition has a special textedit or a key the user should press before any 'special' input, which frankly seemed lame to me even before I started coding. The current solution, as I said, came from a DOS project (with better gui than Windows 3.1 to be honest
), which listens for every possible input there is, thus freeing the user from having to focus a specific control.
Thanks again
Bookmarks