17 setAttribute(Qt::WA_AcceptTouchEvents);
19 m_lstCols << Qt::cyan << Qt::green << Qt::blue << Qt::black
20 << Qt::red << Qt::magenta << Qt::darkYellow
21 << Qt::gray << Qt::darkCyan << Qt::darkBlue;
27 QPainter painter(
this);
28 painter.setRenderHint(QPainter::Antialiasing,
true);
30 int nColsCount = m_lstCols.count();
31 foreach (QTouchEvent::TouchPoint tp, m_lstTps) {
33 case Qt::TouchPointStationary:
36 QColor c(m_lstCols.at(tp.id() % nColsCount));
40 QRectF r1(tp.pos(), QSize(20, 20));
41 QRectF r2(tp.startPos(), QSize(20, 20));
42 painter.drawEllipse(r1.translated(-10, -10));
43 painter.drawEllipse(r2.translated(-10, -10));
45 painter.drawLine(tp.pos(), tp.startPos());
51 bool MultiTouchWidget::event(QEvent* pe)
54 case QEvent::TouchBegin:
55 case QEvent::TouchUpdate:
56 case QEvent::TouchEnd:
58 QTouchEvent* pte =
static_cast<QTouchEvent*
>(pe);
59 m_lstTps = pte->touchPoints();
63 return QWidget::event(pe);