What is the m_bflag for? No matter what it is, you use it incorrectly. You surely shouldn't zero the flag in a paint event.
What is the m_bflag for? No matter what it is, you use it incorrectly. You surely shouldn't zero the flag in a paint event.
What happens if you drag a line and suddenly some window from another application pops up obscuring a part of your widget? A paint event will come and as your flag will be set to false by the previous paint event, the "dynamic" line will not be redrawn. Instead you should clear the flag in mouseReleaseEvent. And don't use the flag - just clear m_lastPt - it'll return true on QPoint::isNull() call. Then it's only a matter of checking that point in the paint event and drawing the line only if isNull() returns false. Just look at one of my previous examples.
Bookmarks