[PySide] CustomButton alpha image

16 views
Skip to first unread message

Rémi Deletrain

unread,
Jul 12, 2017, 6:10:40 AM7/12/17
to Python Programming for Autodesk Maya
Hy everybody,

I try to make a customButton with alpha image.
The objectif is to change color of icon from alpha.

I have a code works but I have two probleme...
    - My picture does not have antialiazing, but my painter have flage.
    - It's impossible to scale image.

The code :
def paintEvent(self, qt_event):

        qt_painter = QtGui.QPainter(self)
        
        qt_color = QtGui.QColor(100, 200, 100, 255)
        qt_region = QtGui.QRegion(self._qt_pixmap.mask())

        qt_painter.setClipRegion(qt_region)
        qt_painter.setRenderHint(QtGui.QPainter.Antialiasing)
        qt_painter.setRenderHint(QtGui.QPainter.RenderHint.HighQualityAntialiasing)
        
        qt_painter.fillRect(self.rect(), qt_color)

        qt_painter.end()

My picture has a size 30px.
My widget has a size 90px.
If I set custom rect in "fillRect" nothing change... draw always have 30px 

Anyone have a solution ?
Reply all
Reply to author
Forward
0 new messages