Home > Mobile >  Qt window set transparent show black, big help
Qt window set transparent show black, big help

Time:04-28

Environment: Linux, qt5.6.3 cross-compilation

Superposition of two window, the window above set transparent, control is not transparent, the results above the part of a display window transparent black,

Window above constructor is set as follows:
UI - & gt; SetupUi (this);
SetAutoFillBackground (false);
SetWindowFlags (Qt: : Dialog | Qt: : FramelessWindowHint);
The setAttribute (Qt: : WA_TranslucentBackground, true);//set the main form transparent background, child controls don't accept influence
Move (START_X + 10, START_Y + 45);


Results are as follows: four Angle circle should be transparent, the results showed that black,


I the window above is the rectangular 218 * 250, then I put the window is set to transparent, apply for a qlable control inside the window, the control is a 218 * 250, qlable control set the background image is 218 * 250, four angles of the background image is transparent color,
Four Angle display time is transparent, so should the impression of display window, the window is transparent, he should be below the window content, the result it shows black!!!!!

Big help, how is this to return a responsibility excuse me? How to solve?

CodePudding user response:

Draw a rounded rectangle with drawRoundedRect first, and then use setmask filter, finally put your background picture painted, I did this round window, you can try
 
Void MainFrame: : setWindowCircle ()
{
//generate a bitmap
QBitmap objBitmap (size ());
//QPainter used for painting on the bitmap
QPainter painter (& amp; ObjBitmap);
//fill the bitmap rectangular box (filled) with white
Painter. FillRect (the rect (), Qt: : white).
Painter. SetBrush (QColor (0, 0));
//to draw on the bitmap rounded rectangle (black color)
Painter. DrawRoundedRect (this - & gt; The rect (), 10, 10);
//use setmask filter can
SetMask (objBitmap);
}

 
Void MainFrame: : paintEvent (QPaintEvent * event)
{
SetWindowCircle ();
QPainter painter (this);
Painter. DrawPixmap (QRect (0, 0, this - & gt; Width (), and this - & gt; Height ()), QPixmap (" :/images/frame_1. JPG "));
}

But I haven't used Linux, don't know the different
  •  Tags:  
  • Qt
  • Related