You can set a mask(but you will get rough edges) or you can first fill the widget with a transparent color or transparent pixmap and then paint on it.

But this will only work as long as the widget''s position is restricted to its parent bounds(won't work for floating widgets).