[Qt-interest] Updating the QPlainTextEdit's background color

NoRulez norulez at me.com
Tue Jul 26 22:26:49 CEST 2011


I've forgotten to say that I use these in a function within a subclass of QPlainTextEdit.

This function/slot is triggered if the font settings have changed.

If I open a new QPlainTextEdit, the new palette settings are present, but I want to change the palette settings for already opened QPlainTextEdit's too.

Best Regards
NoRulez


Am 26.07.2011 um 22:12 schrieb Diego Iastrubni <diegoiast at gmail.com>:

> I am using this code (from the main window)
> 
> QPalette p( palette() );
> p.setColor( QPalette::Base, someColor );
> textEdit->setPalette( p );
> 
> Looks similar to yours, tough.
> 
> 
> On Tue, Jul 26, 2011 at 1:52 PM, NoRulez <norulez at me.com> wrote:
>> Hi,
>> 
>> 
>> 
>> I’m trying to set the background color of a QPlainTextEdit as followed:
>> 
>> 
>> 
>> QPalette pal = palette();
>> 
>> pal.setColor(QPalette::Base, Qt::yellow);
>> 
>> setPalette(pal);
>> 
>> 
>> 
>> But the background color doesn't change.
>> 
>> 
>> 
>> I also tried each of the following functions after “setPalette(pal);”, but
>> the result is the same (which means that the background color isn't changed)
>> 
>> .) update();
>> 
>> .) repaint();
>> 
>> .) viewport()->update();
>> 
>> 
>> 
>> So, which method can I call to change the background color immediately.
>> 
>> 
>> 
>> Thanks in advance
>> 
>> 
>> 
>> Best Regards
>> 
>> NoRulez
>> 
>> _______________________________________________
>> Qt-interest mailing list
>> Qt-interest at qt.nokia.com
>> http://lists.qt.nokia.com/mailman/listinfo/qt-interest
>> 
>> 



More information about the Qt-interest-old mailing list