2011-09-06 204 views
3

如何設置背景圖片爲QLineEdit?下面的樣式表不起作用QLineEdit背景圖片

QLineEdit { 
    background-image:url(:/images/13.png); 
} 

回答

2
QLineEdit { 
    border: 1px solid #000000; //image work with this line and didn't work with out)) 
    image: url(:/images/13.png); 
} 
+0

謝謝您的回答,我已經刪除「:」從我的問題。然而,改爲「圖像:」並沒有幫助。我設法爲'QProgressBar'實例設置背景圖片。這是否意味着QLineEdit不支持此功能? – Andrey

+0

它適合我。你確定嗎:/images/13.png? – TheHorse

+0

哈哈。多一個bug!我會更新我的回答 – TheHorse

1
更好

的解決方案是:

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