I think the one line that may fix it would be this:

painter.setCompositionMode(painter.CompositionMode_Source)

It tells the painter to just copy the new pixel, without considering the 
destination pixels alpha. It may related to how the drawEllipse handles the 
area outside the shape, over the previously drawn transparent pixels

I didn't need to do it with a pixmap or image first, but then again I am not 
sure what you will be doing in this paint method beyond this test example:

        def paint(self, painter, rect, mode, state):

                painter.setRenderHint(painter.Antialiasing)
                painter.setCompositionMode(painter.CompositionMode_Source)

                painter.fillRect(rect, QtCore.Qt.transparent)

                painter.setPen(QtGui.QPen(QtCore.Qt.red))
                painter.setBrush(QtGui.QBrush(QtCore.Qt.red))        
                painter.drawEllipse(rect)  



On Sep 8, 2012, at 7:35 PM, Manuel Macha wrote:

> I'm having a hard time figuring out how to best deal with transparencies 
> using QPainter (PyQt 4.7 on Mac OSX)
> I'm getting noisy artifacts in transparent areas of my icon which is painted 
> using a custom QIconEngine class 
> http://pastebin.com/ES55EeQj
> 
> I'm trying to follow the advice in these articles where I explicitly set the 
> pixelFormat in a pixmap and then fill it with transparency, however I can't 
> get rid of the artifacts.
> http://techbase.kde.org/Development/Tutorials/Graphics/Performance
> http://www.informit.com/articles/article.aspx?p=1174421&seqNum=3
> 
> Any help would be greatly appreciated.
> 
> 
> -- 
> view archives: http://groups.google.com/group/python_inside_maya
> change your subscription settings: 
> http://groups.google.com/group/python_inside_maya/subscribe

-- 
view archives: http://groups.google.com/group/python_inside_maya
change your subscription settings: 
http://groups.google.com/group/python_inside_maya/subscribe

Reply via email to