I have subclassed a widget, a QSlider, and styled it so it has large transparent margins. This makes it much easier to grab on a touchscreen. However, the margin extends under some buttons to the right of the slider. This causes the buttons to redraw when the slider is moved, which is very slow. If I make the slider narrow, so it does not have the margins, then it renders fast and the buttons do not redraw. I think I would like the margins to exist for the purposes of touch detection, but not for the purposes of dirty rect propagation.

I tried to change the visible region the paint event, but it only affected the slider drawing itself - it did not affect the buttons being redrawn.
Qt Code:
  1. def paintEvent(self, evt):
  2. clippedEvt = QPaintEvent(self.visibleRegion())
  3. super().paintEvent(clippedEvt)
To copy to clipboard, switch view to plain text mode 
So I downloaded the source code, and in qt-everywhere-opensource-src-5.7.1/qtbase/src/widgets/kernel/qwidget.cpp:10966, in the QWidget::update function, it looked like it was responsible for figuring out where the update rect was. I think it just uses the bounding box of the widget.

I would like to use the visual bounding box, however, instead of the real one, for the purposes of repainting. To do this, I tried overriding the update function in my subclass, like this:
Qt Code:
  1. def update(arg):
  2. print('update event', arg)
To copy to clipboard, switch view to plain text mode 
However, I can not get my slider to print update event. It appears it still uses the parent class' update event to schedule updates.

So I tried overriding the rect function, because I see update uses that. I don't think this will work, since I bet this is also used for touch intersection calculation. But it is no matter, because it too has no effect.
Qt Code:
  1. def rect(self):
  2. print('update rect')
  3. return QRect(30, 10, self.width()-30, self.height-10)
To copy to clipboard, switch view to plain text mode 

Is there another way to make my widgets, far away and above the transparent margin, not redraw themselves? Or have I taken the wrong approach?

Thanks!
–DDR