Hi,

I'm using NightCharts to draw 3 piecharts on a QDialog. When I draw those three charts in paintEvent() and run the program, one of the charts is not painted fully. But when I resize the QDialog manually, the incomplete chart is now fully painted. How do I make this paint properly.

Qt Code:
  1. void Dialog::paintEvent(QPaintEvent *event)
  2. {
  3. Q_UNUSED(event);
  4. QPainter painter(this);
  5. addGraphs(&painter);
  6. }
  7.  
  8. void Dialog::addGraphs(QPainter *qp)
  9. {
  10. Nightcharts chart1;
  11. chart1.setShadows(false);
  12. chart1.setType(Nightcharts::Pie);
  13. chart1.setLegendType(Nightcharts::Vertical);
  14. chart1.setCords(50, 50, 80, 80);
  15. chart1.addPiece("Item1",QColor(200,10,50),34);
  16. chart1.addPiece("Item2",Qt::green,27);
  17. chart1.addPiece("Item3",Qt::cyan,14);
  18. chart1.addPiece("Item4",Qt::yellow,7);
  19. chart1.addPiece("Item5",Qt::blue,4);
  20. chart1.draw(qp);
  21. // chart1.drawLegend(qp);
  22.  
  23. Nightcharts chart2;
  24. chart2.setShadows(false);
  25. chart2.setType(Nightcharts::Pie);
  26. chart2.setLegendType(Nightcharts::Vertical);
  27. chart2.setCords(300, 50, 80, 80);
  28. chart2.addPiece("Item2",Qt::green,45);
  29. chart2.addPiece("Item3",Qt::cyan,25);
  30. chart2.addPiece("Item4",Qt::yellow,15);
  31. chart2.addPiece("Item5",Qt::blue,15);
  32. chart2.draw(qp);
  33. // chart2.drawLegend(qp);
  34.  
  35. Nightcharts chart3;
  36. chart3.setShadows(false);
  37. chart3.setType(Nightcharts::Pie);
  38. chart3.setLegendType(Nightcharts::Vertical);
  39. chart3.setCords(550, 50, 80, 80);
  40. chart3.addPiece("Item1",QColor(200,10,50), 25);
  41. chart3.addPiece("Item3",Qt::cyan, 25);
  42. chart3.addPiece("Item4",Qt::yellow, 15);
  43. chart3.addPiece("Item5",Qt::blue, 15);
  44. chart3.draw(qp);
  45. // chart3.drawLegend(qp);
  46. }
To copy to clipboard, switch view to plain text mode 

Before resizing QDialog
OnExec.jpg

After resizing QDialog
Resize.jpg

Kindly help me. Thank you.