[Interest] QTextEdit and Style sheets
André Somers
andre at familiesomers.nl
Wed Mar 14 09:17:20 CET 2012
Op 13-3-2012 17:26, Christoph Feck schreef:
> On Tuesday 13 March 2012 16:52:21 André Somers wrote:
>> Op 13-3-2012 16:45, Graham Labdon schreef:
>>> Hi everyone
>>>
>>> Solved this!
>>>
>>> edit->setStyleSheet("background-image:url(:/images/bg.jpg)");
>>>
>>> QPalettepalette=edit->palette();
>>>
>>> palette.setBrush(QPalette::Base,Qt::NoBrush);
>>>
>>> edit->setPalette(palette);
>> Please report this as a bug. I think that setting a background
>> image should already set the brush to NoBrush, or the rendering
>> should be done the other way around. Either way, that would
>> qualify as a Qt bug IMO.
>>
>> André
> You have to change the background of the viewport() instead, otherwise
> the viewport will render its background over that of the QTextEdit
> object. So it is not a bug, but expected behavior. Using setPalette()
> also affects the viewport, because the palette attribute is inherited
> by children.
>
That doesn't feel natural at all, from a stylesheet point of view. What
other background than the background provided by the viewport could be
styled with setStyleSheet on a text exit? The viewport is not even
accessible from Designer. Or should you use the child-of selector in
style sheet instead?
edit->setStyleSheet("QTextEdit QWidget {background-image:url(:/images/bg.jpg);}");
That looks weird. And why would that only be needed for the background
image? Setting the color of the text or even of the background, which is
also rendered on the view port, *does* work directly.
I feel we really have a bug on our hands here.
André
More information about the Interest
mailing list