Search code examples
c++qtqwt

Hide bounding rect of a custom QwtSymbol


I have a class that derives from QwtSymbol, the symbol type is pixmap. On the pixmap, I draw an ellipsis, however, when a curve with the custom symbol collides with another curve (with a standard symbol), the custom symbol clips the symbol area of another curve.

The custom symbol clips other symbols only where it collides with the bounding rect.

CSymbol::CSymbol()
    : QwtSymbol(QwtSymbol::Pixmap)
    , ellipsis(142, 142, 142)
{
    QPixmap pixmap(QIcon(":/App/Resources/Ellipsis.png").pixmap(QSize(12, 12)));
    QPainter* painter = new QPainter(&pixmap);
    QwtPainter qwtPainter;

    QPen pen(ellipsis);
    pen.setWidth(1);

    painter->setRenderHint(QPainter::Antialiasing);
    painter->setClipping(false);
    painter->setPen(pen);
    auto size = QRectF(1, 1, 10, 10);
    qwtPainter.drawEllipse(painter, size);
        painter->end();
    setPixmap(pixmap);
    setPinPoint(QPoint(0, 0), true);

How can I hide the bounding rect of the custom symbol so that it doesn't clip the overlaying stuff?


Solution

  • The solution is quite trivial, I've just applied alpha blending to the input pixmap and after that drew the ellipsis.