Hello Qt users,

I encountered a small issue while integrating a code editor in my plateform.
My editor is based on the one described here, and the issue comes with painting the lines numbers.

I've added the possibility to change the font size to my editor. Unfortunately, in the line number area paint event, this font change cannot be simply reported to the painter.

Qt Code:
  1. void CodeEditorQt::lineNumberAreaPaintEvent(QPaintEvent* event) {
  2.  
  3. // Here we paint the zone of the editor corresponding to the line numbers
  4. QPainter painter(_lineNumberArea);
  5.  
  6. [...]
  7.  
  8. painter.setPen( Qt::white );
  9. painter.setFont( font() ); // <- here 'this' is the QPlainTextEdit whose font size has changed
  10.  
  11. // If the editor's font has changed, we have at this point
  12. // font().pointSize() != painter.font().pointSize()
  13.  
  14. [...]
  15.  
  16. }
To copy to clipboard, switch view to plain text mode 

As a consequence, the line numbers will be always printed with the initial font size.

Is this the desired behaviour or I am doing something wrong?

Thanks in advance for your answers.

Gael

Nota: I've figgured out a way to hack this by scaling directly the painter but it's not a very clean solution