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)