[PyQt] rounded corners on a qlabel used as a top level window

Henning Schröder henning.schroeder at gmail.com
Thu Feb 11 22:13:54 GMT 2010


On Thu, Feb 11, 2010 at 10:42 PM, Victor Noagbodji
<noagbodjivictor at gmail.com> wrote:
>
> hello all,
>
> if you visit http://jsgrowl.com/, you will see nice modal and
> semi-modal windows. the idea is to reproduce them using pyqt. i
> started with a qlabel. used html for the content. set the window flag
> to Qt.SplashScreen. and applied my stylesheet.
>
> but the squared corner is not going way.

You can use QWidget.setMask
Here is a demo how to show a splash screen with a non-rectangular
splash screen (using a png with alpha background)

splash = QSplashScreen()
img = QImage("splash.png")
pm = QPixmap.fromImage(img)
if not pm.mask():
    if img.hasAlphaBuffer(): bm = img.createAlphaMask()
    else: bm = img.createHeuristicMask()
    pm.setMask(bm)
if pm.mask(): splash.setMask(pm.mask())
splash.setPixmap(pm)
splash.show()
splash.finish(main_window)

Henning


More information about the PyQt mailing list