A qt widget with fully transparent background(具有完全透明背景的 qt 小部件)
问题描述
我需要创建一个 qt 小部件,它将充当其他一些小部件的父级,并为它们排序.
I need to create a qt widget, which will act as a parent for some other widgets, and which will order them.
现在的问题是如何让它的背景完全透明?
Now, the question is how do I make it's background fully transparent?
我想这样做:
struct Imp
{
Imp( QWidget *parent ) : thisWidget( new QWidget( parent ) )
{
thisWidget->setAttribute( Qt::WA_TranslucentBackground, true );
}
QWidget *thisWidget;
};
你认为我需要设置属性,还是没有它会正常工作?
Do you think that I need to set the attribute, or is it going to work fine without it?
推荐答案
在 Qt4 中默认情况下,QWidget 不会为自己的背景绘制任何内容,只会绘制其子项.如果你想覆盖它,你必须特别告诉小部件通过它的属性之一来绘制它的背景.请注意,从 QWidget 派生的一些小部件会自动绘制背景.
By default in Qt4, a QWidget will draw nothing for its own background, and only its children will be drawn. If you want to override that, you specifically have to tell the widget to draw its background via one of its properties. Note that some widgets derived from QWidget will automatically draw backgrounds.
这篇关于具有完全透明背景的 qt 小部件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:具有完全透明背景的 qt 小部件


- 近似搜索的工作原理 2021-01-01
- C++ 协变模板 2021-01-01
- 如何对自定义类的向量使用std::find()? 2022-11-07
- 静态初始化顺序失败 2022-01-01
- 与 int by int 相比,为什么执行 float by float 矩阵乘法更快? 2021-01-01
- 一起使用 MPI 和 OpenCV 时出现分段错误 2022-01-01
- 使用/clr 时出现 LNK2022 错误 2022-01-01
- STL 中有 dereference_iterator 吗? 2022-01-01
- Stroustrup 的 Simple_window.h 2022-01-01
- 从python回调到c++的选项 2022-11-16