Qt-interest Archive, July 2006
Background color of QTextEdit in QT 4
Message 1 in thread
Hi,
in QT3 I had set the background color of a QTextEdit with
setPaper (const QBrush &pap)
How can this be done in QT 4?
Best,
Uwe
--
[ signature omitted ]
Message 2 in thread
just reading the doc.... I suppose you'll have to use
void QWidget::setBackgroundRole ( QPalette::ColorRole
<http://zorro/developpement/documentation/qt4.1.3/html/qpalette.html#ColorRole-enum>
/role/ )
Uwe Drechsel a écrit :
>Hi,
>
>in QT3 I had set the background color of a QTextEdit with
>
> setPaper (const QBrush &pap)
>
>How can this be done in QT 4?
>
>
>Best,
>
> Uwe
>
>
>
Message 3 in thread
On Thu, Jul 06, veronique.lefrere@xxxxxx wrote:
> just reading the doc.... I suppose you'll have to use
> void QWidget::setBackgroundRole ( QPalette::ColorRole role )
>
>
I already tried that. For a QScrollArea it seems to work, but so far
I failed to convince QTextEdit to change anything.
I also played around e.g with examples/widgets/tooltips/sortingbox.cpp,
also no visible effect while changing BackroundRole.
Thanks anyway,
Uwe
--
[ signature omitted ]
Message 4 in thread
On Thu, Jul 06, Uwe Drechsel wrote:
> On Thu, Jul 06, veronique.lefrere@xxxxxx wrote:
>
> > just reading the doc.... I suppose you'll have to use
> > void QWidget::setBackgroundRole ( QPalette::ColorRole role )
> >
> >
>
> I already tried that. For a QScrollArea it seems to work, but so far
> I failed to convince QTextEdit to change anything.
>
> I also played around e.g with examples/widgets/tooltips/sortingbox.cpp,
> also no visible effect while changing BackroundRole.
>
For the latter one it works after adding
setAutoFillBackground (true);
The default is false, so the call to setBackgroundRole in the unmodified
example is useless.
Grüsse,
Uwe
--
[ signature omitted ]
Message 5 in thread
On Thu, Jul 06, Uwe Drechsel wrote:
> >
> > I already tried that. For a QScrollArea it seems to work, but so far
> > I failed to convince QTextEdit to change anything.
> >
> > I also played around e.g with examples/widgets/tooltips/sortingbox.cpp,
> > also no visible effect while changing BackroundRole.
> >
Of course setting the palette for the widget does the trick, as
Veronique showed me.
QPalette p=palette();
p.setColor(QPalette::Active, static_cast<QPalette::ColorRole>(9), QColor (Qt:gray);
e->setPalette(p);
Best,
Uwe Drechsel
--
[ signature omitted ]