Qt-interest Archive, January 2007
QLineEdit background color role
Message 1 in thread
Isn't there a way to disable the background for a line edit? I want it
to display the text with the widget underneath showing through. Funny
enough, I can't even find a color role that affects the line edit
background? ideas?
thanks
-P
--
[ signature omitted ]
Message 2 in thread
Patrick Stinson wrote:
> Isn't there a way to disable the background for a line edit? I want it
> to display the text with the widget underneath showing through. Funny
> enough, I can't even find a color role that affects the line edit
> background? ideas?
>
QPalette::Base is the role you are looking for.
--Justin
begin:vcard
begin:vcard
fn:Justin Noel
n:Noel;Justin
org:ICS;Engineering
adr:;;54B Middlesex Trpk;Bedford;MA;01730;USA
email;internet:justin@xxxxxxx
title:Sr. Consulting Engineer / Certified Qt Instructor
tel;work:(617) 621-0060
url:http://www.ics.com
version:2.1
end:vcard
Message 3 in thread
Got it
class Widget : public QWidget
{
Q_OBJECT
public:
Widget(QWidget *parent = 0)
: QWidget(parent)
{
QVBoxLayout *l = new QVBoxLayout(this);
QLineEdit *edit = new QLineEdit("This is a line edit", this);
QPalette pal = edit->palette();
pal.setColor(edit->backgroundRole(), Qt::transparent);
edit->setPalette(pal);
l->addWidget(edit);
}
void paintEvent(QPaintEvent *)
{
QPainter p(this);
p.fillRect(rect(), QColor("brown"));
p.drawLine(0, 0, width(), height());
p.drawLine(width(), 0, 0, height());
}
public slots:
};
On 1/4/07, Justin Noel <justin@xxxxxxx> wrote:
> Patrick Stinson wrote:
> > Isn't there a way to disable the background for a line edit? I want it
> > to display the text with the widget underneath showing through. Funny
> > enough, I can't even find a color role that affects the line edit
> > background? ideas?
> >
>
> QPalette::Base is the role you are looking for.
>
> --Justin
>
>
>
--
[ signature omitted ]