In the embedded platform, the QT we use will be run in a qws way, that will run the Qwsserver, and then run the actual form, in which case the default QWS background will be green, and in the embedded, many scenarios will be the video and the graphic layer apart, the two layers of the cascade is also adjustable, When you need to do some control on the video icon and so on, you need to move the GFX to the vid above, this time need to run the GFX QT program set the background transparent, a total need to set two: one is Qws, one is the form. In this respect, we use Qtcreator to create a widget based program (that is, to inherit from the Qwidget Class) and add the following code to the constructor: SetAttribute (Qt::wa_translucentbackground); You can set the form background to be transparent, and to make the QWS background transparent, you add the following code: 1, add header file #include< qwsserver>; 2, add in the above constructor: Qwsserver::setbackground (QC Olor (0,0,0,0)); At this point, you can achieve the target functional requirements, the above code is in the QT4.5 environment, and when used to QWS, only on the QVFB or embedded platform to run only can use, and the use of framebuffer to be set to ARGB8888, rather than ARGB1555, In order to make the function effective, we use QT compilation is 32-bit framebuffer, so the use of ARGB8888. The code for using ARGB8888 is as follows:
static struct Fb_bitfield g_r16 = {8, 0};
static struct Fb_bitfield G_g16 = {8, 8, 0};
static struct Fb_bitfield G_b16 = {0, 8, 0};
static struct Fb_bitfield g_a16 = {24, 8, 0};
The code for setting Qwsserve is as follows:
Qwsserver::setbackground (Qcolor (0,0,0,0));
Set the transparent code for the drawing layer as follows (transparent to display the underlying video layer)
if (IOCTL (FD, FBIOGET_ALPHA_HIFB, &stalpha))
{
sample_prt ("Get ALPHA failed!\n");
Close (FD);
return hi_null;
}
stalpha.balphaenable = hi_true; /* Superposition make can * *
stalpha.balphachannel = hi_false;
Stalpha.balphachannel = hi_true;
STALPHA.U8ALPHA0 = 0xFF;
STALPHA.U8ALPHA1 = 0xFF;
Stalpha.u8globalalpha = 0x80;
if (IOCTL (FD, FBIOPUT_ALPHA_HIFB, &stalpha) < 0) //Set overlay layer of alpha
{
printf ("Set ALPHA failed!\n"); Close
(FD);
return hi_null;
}
Reference URL: http://mypyg.blog.51cto.com/820446/172661 HTTP://BLOG.CSDN . net/fh400/archive/2010/05/17/5600458.aspx Http://blog.csdn.net /goodlixueyong/archive/2010/10/18/5948486.aspx http:// Blog.csdn.net/lbsljn/archive/2009/12/29/5099590.aspx