Hi All !

I would like to create some vector graphics ballons that can be customized by the user (changing the scale factors and position of the stem.

Internally I use QPainter to draw all the balloons stuff including the balloons shapes.

For every type of balloon I create, on the fly, a QPainterPath from an union of several polygons.

I try to do something like this with a strange results that probably depends from the painterpath position:



The code (very straightfoward and not optimize) is the following:

Qt Code:
  1. QPolygonF Balloon::getSoftPolygon()
  2. {
  3. int w = m_rect.width();
  4. int h = m_rect.height();
  5.  
  6. QPoint center = m_rect.center()-QPoint(w*0.25,h*0.25);
  7. QRect smallRect(center.x(),center.y(),w*0.5,h*0.5);
  8.  
  9. s2.addEllipse(smallRect.translated(w*0.2,0));
  10.  
  11. s3.addEllipse(smallRect.translated(-w*0.2,0));
  12.  
  13. s4.addEllipse(smallRect.translated(w*0.1,-h*0.2));
  14.  
  15. s5.addEllipse(smallRect.translated(-w*0.1,-h*0.2));
  16.  
  17. s6.addEllipse(smallRect.translated(w*0.1,h*0.2));
  18.  
  19. s7.addEllipse(smallRect.translated(-w*0.1,h*0.2));
  20.  
  21. QPolygonF p = s2.united(s3).united(s4).united(s5).united(s6).united(s7).toFillPolygon();
  22. return p;
  23. }
To copy to clipboard, switch view to plain text mode 

Then in the paintEvent...

Qt Code:
  1. QPolygonF stemPolygon = getStemPolygon();
  2.  
  3. QPainterPath overallShape = QPainterPath();
  4. overallShape.addPolygon(getSoftPolygon().united(stemPolygon));
To copy to clipboard, switch view to plain text mode 

Probably exist a more simple way to create a "soft" balloon using QPainterPath.
Any suggestions and different solution are welcome !!

Bye, bye !