本文介绍了删除而QListView背景的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要删除我而QListView的背景,使下面的背景可以识破。我该怎么做?

I want to remove the background of my QListView so that the background below can be seen through. How can I do that?

我试过的setAttribute(Qt的:: WA_NoSystemBackground)的setAttribute(Qt的:: WA_NoBackground)但没' T改变任何东西。我也不能覆盖的paintEvent(),否则它不会画的项目。

I tried setAttribute(Qt::WA_NoSystemBackground) and setAttribute(Qt::WA_NoBackground) but that didn't change anything. Also I cannot override paintEvent() otherwise it doesn't draw the items.

任何想法?

推荐答案

不要忘了QScrollArea,这是基类,而QListView包含另一个控件,它被称为视口。它可以通过视()方法accesed。

Don't forget that QScrollArea, which is base class for QListView contains "another" widget which is called Viewport. It can be accesed via viewport() method.

要实现透明你可以简单地只要致电:

To achieve transparency You can simply just call:

viewport()->setAutoFillBackground( false );

和取决于其他设置(即父窗口小部件设置)你应该可以看到背景。

and depending on other setting (i.e. parent widget settings) You should see background.

这篇关于删除而QListView背景的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-04 04:09