Painting
When you override QWidget.paintEvent(QPaintEvent event) in your subclass of the widget to perform some custom drawing, you usually create a QPainter object that is owned by the widget. By default all objects are allocated on the heap, so you might type something like that:
void paintEvent(QPaintEvent event) { auto painter = new QPainter(this); ... // drawing }
In C++ you allocate QPainter on the stack and it is destroyed after exiting paintEvent() scope. In case it doesn't it will cause problems in Qt drawing system. In order to avoid them you should make sure painter is destroyed after paintEvent() is executed which you can easily achieve by creating it with the qtd.QtdObject.scoped function:
void paintEvent(QPaintEvent event) { auto painter = scoped!QPainter(this); ... // drawing }
