Several transparent effects under QT (Qpalette Background white, window settings Setwindowopacity,qpainter drawing with clear mode)

Source: Internet
Author: User

1. The window is overall transparent, but the controls on the form are opaque. This is done by setting the background color of the form and setting the background color to full-transparent. Qpalette pal = palette ();
Pal.setcolor (Qpalette::background, Qcolor (0x00,0xff,0x00,0x00));
SetPalette (PAL);    Test effect: The form title bar is opaque, the controls on the form client area are opaque, the Qlabel control is just a word display, the control background color is transparent, and the form client area is completely transparent. Another way to see it from the Internet: SetAttribute (Qt::wa_translucentbackground,trueThe result of the test is similar to the method above, but sometimes the form is filled with some noise spots and no reason is found. 2. The window and the controls above are translucent: setwindowopacity (0.7) Experimental effect: Both the window and the controls are translucent. 3. Window overall opaque, local transparency: Use clear mode drawing in the Paint event.voidTestwindow::p aintevent (qpaintevent*)
{
Qpainter P ( This);
P.setcompositionmode (qpainter::compositionmode_clear);
P.fillrect (Ten, Ten, A, qt::solidpattern);
The test effect: the drawing area is fully transparent.  Controls are not affected if the drawing area has controls. The above experiments are based on the DIRECTFB QTE test. The effect is slightly different under Linux and under Windows. For example, in the 3rd experiment under Windows, the plot area is a black hole, if the window itself is semi-transparent, then the content below the window plus a semi-transparent effect, not the full transparency effect. http://mypyg.blog.51cto.com/820446/172661

Several transparent effects under QT (Qpalette Background white, window settings Setwindowopacity,qpainter drawing with clear mode)

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.