QPainter painter(this); QPen pen(Qt::black, 2); painter.setPen(pen); painter.setRasterOp(Qt::XorROP);
QPainter painter(this); QPen pen(Qt::blue, 2); painter.setCompositionMode(QPainter::CompositionMode_Clear); painter.setRasterOp(Qt::NotROP); painter.setPen(pen); painter.drawLine(QPoint(10, 10), QPoint(100, 100));In this example, we again create a QPainter which is used to paint on a widget. We set the pen to use a blue color with a width of 2 pixels. We then set the composition mode to CLEAR, which means that pixels are set to transparent black. We set the raster operation mode to NOT, which means that the pixels drawn will be inverted. Finally, we draw a line from (10, 10) to (100, 100). This code example could be found in the Qt library.