1:The painter parameter in the paint() function can only display images, but not the contents of the drawing process. So I created a new painter to draw the process.
I have no idea what you mean by "draw the process".

The whole process of the mouse drawing is very slow and stuck
image size: 10000 * 10000
What do you expect? You apparently have two images, each of them with 100 million pixels, and you are using an interpreted language to draw them. Of course it will be slow.

And if by "mouse drawing" you mean that you are updating the image with every mouse move, then of course it will deadly slow in any programming language.

You should consider using a QPainterPath to capture the mouse movements instead of setting individual pixels, which is what I think you are doing.