Thank you for your answers.
I avoided the problem by changing the QCPLayerable::setVisible() method from protected to public, and then creating a parent rectangle for the heatmap that is set to invisible.
Then, I create each rectangles of the heatmap as children of the parent invisible rectangle. I set the pen to the desired color at each insertion.
At the end of the addition of the rectangles, I set the parent to visible.
Furthermore, my process is iterative, at each iteration of the algorithm described, the colors need to be updated. To avoid a slow refreshing, I store an array of pointers to the rectangles, and just update the colors with the pen.
With this method, I don't have any slowing problem in my heatmap anymore.