View Full Version : how to change QTextEdit background color ?
mismael85
26th June 2008, 17:54
hello,
i am trying to change the background color so i saw the documentation and used the following code
mainText->setAutoFillBackground(true);
mainText->setPalette(QPalette(QColor(255, 250, 205)));
but the background still white.
how can i change the background color?
please help me.
and thank you.
mainText->setStyleSheet("QTextEdit { background-color: rgb(255, 250, 205); }");
aamer4yu
26th June 2008, 18:31
Quite strange, stylesheet works...but the setPalette doesnt.
Is there some reason why setPalette doesnt work with QTextEdit ???
mismael85
26th June 2008, 18:43
style sheet works but the font is changed.
and i want to display the text with special font.
other thing please what is the class that "setStyleSheet" belongs?
other thing please what is the class that "setStyleSheet" belongs?
Launch Qt Assistant and write "setStyleSheet" to the Index-tab.
JimDaniel
26th June 2008, 19:11
Qt 4.4's QTextEdit also has setTextBackgroundColor(const QColor & color) and setTextColor(const QColor & color).
elcuco
26th June 2008, 19:21
My code currently reads:
QPalette p( palette() );
p.setColor( QPalette::Base, c.currentColorScheme->getColorDef("dsWidgetBackground").getBackground() );
setPalette( p );
And seems to work, but kinda ugly :)
aamer4yu
26th June 2008, 19:28
Qt 4.4's QTextEdit also has setTextBackgroundColor(const QColor & color)
It does have, but it sets only the background of number of chars int he QTextEdit. It doesnt render the whole background of QTextEdit
JimDaniel
26th June 2008, 21:48
Ah, I see. Sorry about that.
mismael85
26th June 2008, 22:05
sorry, but the Qt assitante does not work with me .
because i compiled the Qt on dirve c: from a while.
but now i copied the Qt from c: drive to d:
and the assitante does not work for that reason.
and it says that the documentation file does not exist on c:, but it exists on d:.
i will copy the Qt on c: to be able to open the assitante.
and thank you.
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.