4

How to set background image for QLineEdit? The following style sheet doesn't work

QLineEdit {
  background-image:url(:/images/13.png);
}
Andrey Sboev
  • 7,454
  • 1
  • 20
  • 37

2 Answers2

4
QLineEdit { 
   border: 1px solid #000000;   //image work with this line and didn't work with out))
   image: url(:/images/13.png);
}
TheHorse
  • 2,787
  • 1
  • 23
  • 32
  • Thanks for your answer, i've removed ":" from my question. However changing to "image:" doesn't help. I've managed to set background image for `QProgressBar` instance. Does it mean QLineEdit doesn't support this feature? – Andrey Sboev Sep 06 '11 at 19:26
  • thanks, i'll check your update in a minute. Surprisingly adding `lineEdit->setFrame(false);` solved the problem too – Andrey Sboev Sep 06 '11 at 19:36
  • 2
    hmmm setting a border property doesn't change anything but border itself, using "image" instead of "background-image" makes the image smaller then its actual size, and both keywords works only if "frame" property being set to false – Andrey Sboev Sep 06 '11 at 19:42
1

better solution is:

#fileFilter
{
    background: url(/Users/karelhladky/Pictures/Icons/famfamfam/icons/emoticon_grin.png);
        // there is no need add border property
}