The attached source code represents a minimal repeatable case.
The case is the following:
QMainWindow contains QGraphicsView as a center widget.
The are also dock widgets with QTreeViews.
The redraw problem is easily reproducible if you grab either left or right dock widget's resize bar and start moving it.
On the real project it also occurs when window becomes inactive.
The issue is caused by the push button widget. It occurs only if it is visible in the view. If you scroll the view and hide it, everything is ok.
An important factor is that the button lies before all other elements on the scene (in terms of Z-order). And incorrect drawing occurs only for the items that lie after.
Also note that the text is drawn as a polygon, not as spline or something. Maybe that will help in discovering the problem.
The issue is not reproduced in Qt 5.6 and earlier.
Here is fragment of source code: