一个qt小部件具有完全透明的背景 [英] A qt widget with fully transparent background

查看:357
本文介绍了一个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小部件具有完全透明的背景的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆