This article mainly solves the problem of Transparent Display of qgraphicsjavasactshapeitem, qpixmap, qpainter and other components in QT.
A constant is defined in QT to set the transparent color, that is, QT: transparent, indicating the transparent color of rgba value (0, 0, 0.
In the integration class of qgraphicsabstractshapeitem, you can draw some parts into QT: transparent to set transparency.
In qpainter, you can use setbackgroundmode () to select two different background modes: QT: transparentmode and QT: opaquemode. In QT: transparentmode, the background is transparent. In this case, the setbackground () function of qpainter does not work. In QT: opaquemode mode, the setbackground () of qpainter () function to set the background color of the qpainter class object. In this mode, you can also set the background color to QT: transparent.
Sometimes we need to draw qpainter to qpixmap to prevent flickering. If you need to set the qpixmap transparency, You can first use the qpixmap fill () function to set the scenario to transparent (fill (QT: transparent )).
Qimage: Fill (uint pixelvalue)
Try to fill the transparent color with this fill.
TheImage. Fill (qrgba (255,255,255, 0 ));