Is it not possible to change the font twice during a paintEvent()? The following minimal example causes an infinite loop of paintEvent()s, if the font is changed twice. If I comment any of the setFont() lines out, it works fine.

Qt Code:
  1. class FontRepaint : public QWidget
  2. {
  3. Q_OBJECT
  4.  
  5. public:
  6. FontRepaint(QWidget *parent = 0);
  7. ~FontRepaint(){};
  8.  
  9. protected:
  10. void paintEvent(QPaintEvent*);
  11.  
  12. };
  13.  
  14. FontRepaint::FontRepaint(QWidget *parent)
  15. : QWidget(parent)
  16. {
  17.  
  18. }
  19.  
  20. void FontRepaint::paintEvent(QPaintEvent*)
  21. {
  22. qDebug() << "repaint";
  23. setFont(QFont("Helvetica", 18));
  24. setFont(QFont("Helvetica", 14));
  25. }
To copy to clipboard, switch view to plain text mode