QCustomPlot Discussion and Comments

patch: QCPItemText::draw() restore transform after drawingReturn to overview

QCPItemText::draw() should restore transform after drawing like other widgets do.

void QCPItemText::draw(QCPPainter *painter)
   QPointF pos(position->pixelPosition());
   QTransform transform = painter->transform();
+  QTransform oldTransform = transform;
   transform.translate(pos.x(), pos.y());
   if (!qFuzzyIsNull(mRotation))
@@ -29040,6 +29079,7 @@
     painter->drawText(textRect, Qt::TextDontClip|mTextAlignment, mText);
+    painter->setTransform(oldTransform);

QCPLayerable subclasses don't need to do that, it is handled for them automatically to prevent such mistakes (see QCPLayer::draw).

Why did you think there is a bug, did you observe any behavior that lead you there?

Hi, Manu

The problem only manifests when invoking QCPItemText::draw() directly when painting to QCPPainter.

As i see now, there is additional code that completes QCPItemText::draw() in QCPLayer::draw().

I guess i withdraw my patch.
Even so it is sufficient in my case, it doesnt fit library as whole.

Thank you for help.