QGraphicsitem and protected function Paint



  • 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..


  • Moderators

    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....
    }
    

Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.