Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. TabletEvent positions are not mapped to QGraphicsScene as I think they should

TabletEvent positions are not mapped to QGraphicsScene as I think they should

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 224 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Q Offline
    Q Offline
    QtUser467
    wrote on last edited by
    #1

    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::scenePosition does 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.

    Pl45m4P 1 Reply Last reply
    0
    • Q QtUser467

      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::scenePosition does 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.

      Pl45m4P Offline
      Pl45m4P Offline
      Pl45m4
      wrote on last edited by
      #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 from QTabletEvent.
      QTabletEvent inherits it through QSinglePointEvent but 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()).


      If debugging is the process of removing software bugs, then programming must be the process of putting them in.

      ~E. W. Dijkstra

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved