PDA

View Full Version : how to make lineedit transparent



RENOLD
16th February 2012, 10:42
Hi all,
I have to make one application in which I need to make my Line Edit transparent.....
if anyone knows that How to make Line Edit transparent then please reply.....
:confused:

MarekR22
16th February 2012, 12:33
try: QWidget::windowOpacity-prop

RENOLD
16th February 2012, 13:15
Hey Marek I make it using following code..


QPalette p;
p.setColor(lineEdit->backgroundRole(), Qt::transparent);
lineEdit->setPalette(p);


But The problem is that the border of the line edit is disturbing my project.... Means I also want to make border transparent.... Is there any way to do that???

Added after 26 minutes:

I solve the problem simply using the stylesheet....

lineEdit->setStyleSheet(QString::fromUtf8("border:0px;""background:transparent"));

:)

Spitfire
20th February 2012, 15:24
Try to avoid stylesheets if possible and use QPalette to do what you want.



QPalette palette;
palette.setBrush( QPalette::Base, Qt::transparent );
lineEdit->setPalette( palette );
lineEdit->setFrame( false );
simples.