QCustomPlot Discussion and Comments

QCPItemRect transparencyReturn to overview

I am trying to set the transparency of a QCPItemRect using setBrush with a brush color that has the transparency set. However, the transparency doesn't seem to affect the rendering.

QCPItemRect *failureRect = new QCPItemRect(this);
QBrush brush = QBrush(Qt::SolidPattern);
brush.setColor(qRgba(0,255,0,40));
		failureRect->setBrush(brush);

I think you've confused qRgba with QColor.

Ah, check the documentation: The QColor constructor that takes QRgb (which you create with qRgba) explicitly states that it ignores alpha:
https://doc.qt.io/qt-5/qcolor.html#QColor-3

So just use QColor(0, 255, 0, 40) instead.

Thank you so much! This was driving me crazy. If you look at the qRgba *code* it doesn't look like it's ignoring the alpha which had me confused.