1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | #include "Painter.h" #include <QMouseEvent> #include <QPainter> #include <QPoint> void Painter::paintEvent(QPaintEvent */*event*/) { /* 有問題的code 無法正常呼叫,或是我搞不清楚觀念... paintEvent function是一直執行刷新嗎? */ QPainter painter(this); painter.drawPixmap(0, 0, *pixImg); if(isGood){ const QPoint p(10, 10), p2(200,200); painter.drawLine( p, p2);//painter.drawLine( p,p2); } } void Painter::mousePressEvent( QMouseEvent *e ){ isGood = true; } void Painter::mouseReleaseEvent( QMouseEvent *e ){ } void Painter::mouseMoveEvent( QMouseEvent *e ){ } |
Direct link: https://paste.plurk.com/show/334254