Make some components transparent in QT

Source: Internet
Author: User
Tags transparent color

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 ));

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.