[Qt-interest] QLineEdit background same as QFrame
Eckhard Jokisch
e.jokisch at orange-moon.de
Mon May 18 22:46:40 CEST 2009
My suggestion before creates code like this:
lineEdit = new QLineEdit(widget);
lineEdit->setObjectName(QString::fromUtf8("lineEdit"));
QPalette palette;
QBrush brush(QColor(39, 60, 255, 255));
brush.setStyle(Qt::SolidPattern);
palette.setBrush(QPalette::Active, QPalette::Base, brush);
palette.setBrush(QPalette::Inactive, QPalette::Base, brush);
QBrush brush1(QColor(255, 255, 255, 255));
brush1.setStyle(Qt::SolidPattern);
palette.setBrush(QPalette::Disabled, QPalette::Base, brush1);
lineEdit->setPalette(palette);
So if you want to do it in code this could serve as a template.
On Monday 18 May 2009 20:55:31 Neel Basu wrote:
> On Tuesday 19 May 2009 00:15:52 Ben Swerts wrote:
> > Hi Neel,
> >
> > You need to set QPalette::Base instead of QPalette::Window. Just try it
> > out in Designer. That way you can see the effect immediately.
> >
> > Greets,
> > Ben
>
> Thanks for your reply.
>
> I tried it programatically
> ui->toEdit->setBackgroundRole(QPalette::Base);
> and It didn't work.
>
> I didn't find anything like backgroundRole in designer
>
> Neel
>
> > > I've a QFrame and in that I've a QLIneEdit
> > > default background color of QLineEdit is white
> > > but I want to make its background color the default background color of
> > > the
> > > window.
> > > I've tried the following things but none of them worked.
> > > ui->toEdit->setBackgroundRole(QPalette::Window);
> > >
> > >
> > > ui->toEdit->setStyleSheet("background-color: "+QVariant(ui->toEdit-
> > >
> > > >palette().brush(QPalette::Window)).toString());
> > >
> > > They did not work. background color of the QLineEdit is still white
> > >
> > > any idea ??
> > >
> > > Thanks
> > > Neel
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090518/9b55a16c/attachment.html
More information about the Qt-interest-old
mailing list