View Full Version : How to draw rubber band using XOR

19th September 2009, 21:58

I remember I can create rubber band of various shapes (not just line or rectangle) using XOR in Qt3, now in Qt4 we have QRubberBand, but it only provides line and rectangle shapes.

How can I create rubber band of various shapes (such as polygon, etc.) the same way as in Qt3?

I am using Qt Graphics View Framework...


19th September 2009, 23:19
Using the same way - you can't, as drawing is only allowed in paint events. But you can draw a rubber band of any shape in general. Just do it during a proper event call (or use a dedicated graphics item).

21st September 2009, 13:13
XOR mode has been reintroduced with Qt 4.5. So on platforms, where Qt::WA_PaintOutsidePaintEvent is supported ( X11) you can use it like with Qt3. On platforms like Windows you can post a dummy paint event, catch it using an event filter and paint there.