Qwidget transparent form

Source: Internet
Author: User

1. Set the background color of the form.
Add in the constructorCode, You need to add the header file qpalette or qgui
Qpalette pal = palette ();
Pal. setcolor (qpalette: Background, qcolor (0x00, 0xff, 0x00,0x00 ));
Setpalette (PAL );
You can set the background color of the form to completely transparent.
Effect:
The window is transparent, but the window control is not transparent. The qlabel control only displays words and the control background color is transparent;
The form client area is completely transparent.
2. Use the setattribute function (QT: wa_translucentbackground, true );
In the same constructor, the effect is the same as that in the first method.

3. The window and Its above controls are translucent:
Setwindowopacity (0.7)
This function can adjust the transparency by 10 levels. With the qslider control, it can be used as a control bar.
Effect: the window and controls are translucent.
4. The overall window is not transparent and partial transparency:
Use the Clear mode drawing in the paint event.
Void testwindow: paintevent (qpaintevent *)
{
Qpainter P (this );
P. setcompositionmode (qpainter: compositionmode_clear );
P. fillrect (10, 10,300,300, QT: solidpattern );
}
Test result: the drawing area is completely transparent. Controls in the drawn area do not affect the controls.
The above methods are used well on Windows Vista and Ubuntu 9.10.

 

For more information, see the help document of QT qwidget.

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.