QGraphicsitem and protected function Paint
Solved
General and Desktop
-
Hi,
i am using QGraphicsIitem and i would like make something this in protected function paint:
MyEdge::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *) { if (something) do original paint else i make my custom paint.... }
Is possible somehow do/call original paint function?
Thanks, for advice.. -
Hi, welcome to devnet.
Sure. In C++ you can call base implementation in derived class by prefixing the method call with
BaseClassName::
.
So in this case it would be:void MyEdge::paint(QPainter* painter, const QStyleOptionGraphicsItem* opt, QWidget* w) { if (something) QGraphicsIitem::paint(painter, opt, w); else // i make my custom paint.... }