Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

[Solved]Stippling pattern with QTabletEvent



  • I have a program that utilizes the QTabletEvent to handle wacom tablet input. I have a bug where the press event will timeout periodically, creating a stippling pattern. The implementation of the code:
    @//variables involved
    QPoint drawPath[3];
    bool deviceDown = false;
    void Foo::tabletEvent(QTabletEvent *event)
    {
    switch(event->type)
    {
    case QEvent::TabletPress:
    if(!deviceDown)
    {
    deviceDown = true;
    drawPath[0] = drawPath[1] = drawPath[2] = event->pos();
    }
    break;
    case QEvent::TabletRelease:
    if(deviceDown) deviceDown = false;
    break;
    case QEvent::TabletMove:
    drawPath[2] = drawPath[1];
    drawPath[1] = drawPath[0];
    drawPath[0] = event->pos();

    if(deviceDown)
    {
      //drawCode
    }
     break;
    

    }
    }
    @

    And this is the result:
    !https://t.co/kuzSaMPSUZ(Drawing Example)!

    Thanks in advance.

    Edit: Solved it, it was all in the draw code, had to call up drawPath[2] instead of drawPath[1] in painter.drawLines();


Log in to reply