TabletEvent positions are not mapped to QGraphicsScene as I think they should
-
In an application, I process input from mouse and tablet pens.
These inputs are mapped to scene coordinates, like this:
bool someScene::event(QEvent *event) { ... switch (event->type()) { case QEvent::TabletPress: { QTabletEvent *ev = static_cast<QTabletEvent *>(event); QPointF p = ev->scenePosition(); ... ev->accept(); return true; } case QEvent::GraphicsSceneMousePress: { QGraphicsSceneMouseEvent *ev = static_cast<QGraphicsSceneMouseEvent *>(event); const QPointF p = ev->scenePos(); ... ev->accept(); return true; } ... } ... }This works as long as my notebook screen resolution remains unchanged.
When I switch to a different resolution because I have a projector attached, using xrandr (the projector and my screen then have the same resolution, mirroring content), then strangely the mouse coordinates are at the proper place, but the tablet pointer coordinates are offset (not where the pointer is visible on the screen). When I comment out the Tablet event processing, these inputs are processed as mouse events, and tablet use works as it should. But then of course I don't get the tablet pressure values.
So
QTabletEvent::scenePositiondoes not do what I think it should do. (I don't want to claim it does the wrong thing, it is well possible that I don't understand the mapping completely. But this looks weird to me).The table produces relative move events, btw.
Qt is version 6.2.
-
In an application, I process input from mouse and tablet pens.
These inputs are mapped to scene coordinates, like this:
bool someScene::event(QEvent *event) { ... switch (event->type()) { case QEvent::TabletPress: { QTabletEvent *ev = static_cast<QTabletEvent *>(event); QPointF p = ev->scenePosition(); ... ev->accept(); return true; } case QEvent::GraphicsSceneMousePress: { QGraphicsSceneMouseEvent *ev = static_cast<QGraphicsSceneMouseEvent *>(event); const QPointF p = ev->scenePos(); ... ev->accept(); return true; } ... } ... }This works as long as my notebook screen resolution remains unchanged.
When I switch to a different resolution because I have a projector attached, using xrandr (the projector and my screen then have the same resolution, mirroring content), then strangely the mouse coordinates are at the proper place, but the tablet pointer coordinates are offset (not where the pointer is visible on the screen). When I comment out the Tablet event processing, these inputs are processed as mouse events, and tablet use works as it should. But then of course I don't get the tablet pressure values.
So
QTabletEvent::scenePositiondoes not do what I think it should do. (I don't want to claim it does the wrong thing, it is well possible that I don't understand the mapping completely. But this looks weird to me).The table produces relative move events, btw.
Qt is version 6.2.
@QtUser467 said in TabletEvent positions are not mapped to QGraphicsScene as I think they should:
QTabletEvent *ev = static_cast<QTabletEvent *>(event); QPointF p = ev->scenePosition();I'm not sure if
scenePos()is the right function the retrieve the input event position fromQTabletEvent.
QTabletEventinherits it throughQSinglePointEventbut the documentation states:Tablet events are similar to mouse events; for example, the x(), y(), pos(), globalX(), globalY(), and globalPos() accessors provide the cursor position, and you can see which buttons() are pressed (pressing the stylus tip against the tablet surface is equivalent to a left mouse button). But tablet events also pass through some extra information that the tablet device driver provides; for example, you might want to do subpixel rendering with higher resolution coordinates (globalPosF()), adjust color brightness based on the pressure() of the tool against the tablet surface, use different brushes depending on the type of tool in use (deviceType()), modulate the brush shape in some way according to the X-axis and Y-axis tilt of the tool with respect to the tablet surface (xTilt() and yTilt()), and use a virtual eraser instead of a brush if the user switches to the other end of a double-ended stylus (pointerType()).