QCustomPlot Discussion and Comments

legend has no backgroundReturn to overview

The text in legend is shown correctly. But no matter what brush I set, there is no legend background.

here is my code :

qcpWidget->plotLayout()->clear();
QCPLegend* qcpLegend = new QCPLegend;
QCPAxisRect* qcpAxisRect = new QCPAxisRect(qcpWidget);
qcpWidget->plotLayout()->addElement(qcpAxisRect);
qcpAxisRect->insetLayout()->addElement(qcpLegend, Qt::AlignTop | Qt::AlignRight);
qcpWidget->legend->setBrush(QColor(255, 255, 255, 150));
qcpWidget->legend->setFont(QFont("Arial", 10));


What may cause this issue?

call legend->setLayer("legend")