PDA

View Full Version : Wierd behaviour of transparent QTextEdit



qlands
7th October 2011, 09:08
Hi,

I have a transparent QTextEdit in a widget that has a image background. The only code that I have is to make the backgriound:



void climateCover::resizeEvent ( QResizeEvent * /*event*/ )
{
QString file;
file = ":images/svg/climate.svg";

QSvgRenderer svgfile(file,0);
QImage img(this->size().width(), this->size().height(), QImage::Format_ARGB32);
img.fill(0);
QPainter painter(&img);
svgfile.render(&painter);

QPalette palette;
setAutoFillBackground(TRUE);
palette.setBrush(QPalette::Window,QPixmap::fromIma ge(img));

setPalette(palette);

}


The QTextEdit is on the UI of climateCover.

However when I run the application the QTextEdit gets its own copy of the background! See image:

6947

The only thing that QTextEdit has is autofillbackground = true and and alpha of 127. I also have a QPushButton with the same characteristics of alpha and it works fine.

Any idea what is wrong?

Thanks,
Carlos.

wysota
7th October 2011, 21:35
Did you try setting the background of the text edit to transparent? I think by default it inherits the palette from its parent and thus you end up with the same image as the background.

By the way, wouldn't it be easier to draw the image in the paint event for the widget instead of setting it to the palette of the widget?