Hello all,
I am experience a problem where if I try to draw with pen/tablet input, the widget will draw a line along with circles at points periodically. Such as the following:
problem.png
The code(in context of QTabletEvent, QMouseEvent is coded the same way):
bool deviceDown = false;
{
if(event
->type
() == QEvent::TabletPress) {
deviceDown = true;
drawPath[2] = drawPath[1] = drawPath[0] = event->pos();
}
if(event
->type
() == QEvent::TabletRelease) {
if(deviceDown == true){deviceDown = false;}
}
if(event
->type
() == QEvent::TabletMove) {
drawPath[2] = drawPath[1];
drawPath[1] = drawPath[0];
drawPath[0] = event->pos();
/* DRAW CODE - Commented out due to actual code residing in another class/function.
QPainter painter(&pixmap);
painter.drawLine(drawPath[1], event->pos());
*/
}
}
bool deviceDown = false;
QPoint drawPath[3];
void Editor::TabletEvent(QTabletEvent* event)
{
if(event->type() == QEvent::TabletPress)
{
deviceDown = true;
drawPath[2] = drawPath[1] = drawPath[0] = event->pos();
}
if(event->type() == QEvent::TabletRelease)
{
if(deviceDown == true){deviceDown = false;}
}
if(event->type() == QEvent::TabletMove)
{
drawPath[2] = drawPath[1];
drawPath[1] = drawPath[0];
drawPath[0] = event->pos();
/* DRAW CODE - Commented out due to actual code residing in another class/function.
QPainter painter(&pixmap);
painter.drawLine(drawPath[1], event->pos());
*/
}
}
To copy to clipboard, switch view to plain text mode
I have attempted to use a single point as the last known point, but that failed. Using a QPoint array seams to be the only way to get the widget to draw any lines correctly.
Bookmarks