Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QGraphicsView Painting Intersected Areas with Different Color



  • Hello,
    I draw circles with increasing their rectangle area and then draw lines with different angles with the code below. And that creates intersected areas.

    Cell image

    What I would like to do is to fill every cell shown in the picture with different colors. I tried to get PainterPath of these each cells but I could not figure it out how to do it.

    int rVal = 60;
     int increaseVal = rVal;
    
     QRect center = QRect(mScene->width()/2-(rVal/2),mScene->height()/2-(rVal/2),rVal,rVal);
     QPen pen(Qt::red);
    
     int lastval;
     for (int i = 0 ;i < 10 ; ++i)
     {
         center = QRect(mScene->width()/2-(rVal/2),mScene->height()/2-(rVal/2),rVal,rVal);
         mScene->addEllipse(center,pen,QBrush());
         rVal+=increaseVal;
         lastval = rVal;
     }
    
     QLineF angleline;
    
     /* Set the origin: */
     angleline.setP1(QPointF(mScene->width()/2,mScene->height()/2));
     double angleSize =14.4;
     for (int i =0 ;i < 25; ++i)
     {
         angleline.setAngle(angleSize);
         angleline.setLength(300);
         mScene->addLine(angleline);
         angleSize += 14.4;
     }
    

    Thanks for any suggestions


Log in to reply