简体   繁体   English

如何删除我提供透明背景图像的QDialog的边框?

[英]How to remove the border of a QDialog which I give a transparent background image?

I intended to make a un-rectangle QDialog , so I paint a png image by override QDialog::paintEvent .Everything is okay except there is a gray border shown arrond the dialog.Like this: 我打算制作一个非矩形的QDialog ,所以我通过重写QDialog::paintEvent绘制png图像。除了在对话框周围显示灰色边框之外,一切都还可以。

在此处输入图片说明

I am sure that border is not belong to the image,and I had setWindowFlags(Qt::FramelessWindowHint) and setAttribute(Qt::WA_TranslucentBackground, true) .I tried to set a qss like border-width: 0px but didn't work. 我确定边界不属于图像,并且我有setWindowFlags(Qt::FramelessWindowHint)setAttribute(Qt::WA_TranslucentBackground, true) 。我试图设置一个qss像border-width: 0px但没有用。 Is there any way to remove the border?And why it is shown? 有什么方法可以删除边框?为什么显示边框?

You can create a borderless dialog by setting Qt::FramelessWindowHint window flag : 您可以通过设置Qt::FramelessWindowHint窗口标志来创建无边界对话框:

setWindowFlags(Qt::Window | Qt::FramelessWindowHint);

To make it transparent you should set these attributes : 要使其透明,应设置以下属性:

setAttribute(Qt::WA_NoSystemBackground);
setAttribute(Qt::WA_TranslucentBackground);
setAttribute(Qt::WA_PaintOnScreen);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM