I tried to draw some more information in QChartView so I re-implement paintEvent
virtual void paintEvent(QPaintEvent *event) {
QChartView::paintEvent(event);
OmenChart *mchr = dynamic_cast<OmenChart *>(this->chart());
if(mchr == nullptr)
return;
QPainter painter(this);
const int labelOffset = 2 + 2;
painter.setFont(this->font());
painter.setPen(QPen(Qt::black));
QFontMetrics fm(painter.font());
const OmenScatterSeries *omnSr = mchr->serie();
QVector<QPointF> points = omnSr->pointsVector();
QStringList labels = omnSr->pointLabels();
for (int i(0); i < labels.count(); i++) {
QString pointLabel = labels[i];
// Position text in relation to the point
int pointLabelWidth = fm.width(pointLabel);
QPointF position(points.at(i));
position.setX(position.x() - pointLabelWidth / 2);
position.setY(position.y() - labelOffset);
painter.drawText(position, pointLabel);
}
}
and I am taking these errors
QWidget::paintEngine: Should no longer be called
QPainter::begin: Paint device returned engine == 0, type: 1
QPainter::setFont: Painter not active
QPainter::setPen: Painter not active
QPainter::font: Painter not active
QWidget::paintEngine: Should no longer be called
Any ideas on this ? I had also used painter.begin and end but I took the same errors