[qt5] save and restore painter in drawPrimitive