TabletMove Event not notified
-
Hi everybody, I'm new here. I Usually find the answer to my questions just searching the web, but this time I have an issue and I don't know if it is a bug, a design decision, or I am just missing something.
NOTE: from here on, when I say that a button in the stylus is/isn't pressed I'm referring to a physical button on the side of the stylus or the stylus point indistinguishable. In other words, the point of the stylus is treated as a button as well.
The problem is that when I override the tabletEvent function on a widget to get the pen tablet ("Wacom Intuos pen small" in my case) events, I am notified only when a button in the stylus is pressed. When this happens I get the correct info (pressure, position, etc.). When no button is pressed the tabletEvent function isn't called, even if the stylus is in the proximity of the tablet. This is the code I'm using:
void MainWindow::tabletEvent(QTabletEvent * e) { std::cout << "inside tabletEvent" << std::endl; }
I tried to override the event function on MainWindow (a QWidget) but the events are notified only when a button is pressed, so I guess the "issue" happens before the event function is called. To see if this could be the case, I installed an event filter on the application object:
MainWindow::MainWindow(QWidget *parent) : QWidget(parent) { qApp->installEventFilter(this); } bool MainWindow::eventFilter(QObject * o, QEvent * e) { if (e->type() == QEvent::TabletMove) std::cout << "inside eventFilter - " << o << " - " << this << std::endl; return false; }
Now the message in the eventFilter function is printed always when the stylus is in the proximity of the tablet (even if no button is pressed).
Output when no button is pressed: ... inside eventFilter - 0x17bc8910 - 0x79fe18 inside eventFilter - 0x17bc8910 - 0x79fe18 inside eventFilter - 0x17bc8910 - 0x79fe18 inside eventFilter - 0x17bc8910 - 0x79fe18 ... Output when a button is pressed: ... inside eventFilter - 0x17bc8910 - 0x79fe18 inside eventFilter - 0x79fe18 - 0x79fe18 inside tabletEvent inside eventFilter - 0x17bc8910 - 0x79fe18 inside eventFilter - 0x79fe18 - 0x79fe18 inside tabletEvent inside eventFilter - 0x17bc8910 - 0x79fe18 inside eventFilter - 0x79fe18 - 0x79fe18 inside tabletEvent ...
The first number is the pointer to the receiver object, and the second is the this pointer (MainWindow in this example). 0x17bc8910 is the address of an object I couldn't identified. Looking at the Qt code I came to the conclusion it is kind of a virtual QWindow that the system creates to receive the Wintab events in the first place (just specullating, I don't really know).
As we can see, when a button is pressed the event is notified to the unknown object and then re-notified to this widget (MainWindow in the example), ending in the call to the tabletEvent function. When no button is pressed, the event isn't re-notified, but it is notified to the unknown object.My questions are:
- is this a bug?
- if not, is there a way to be notified in the tabletEvent function when the stylus isn't touching the tablet? (something like setMouseTracking).
- if not, is there a clever way to notify the gui by filtering the event in an application event filter and re-sending it?
I'll be trying to make a hack like explained in the third point.
Thanks in advance.