Issue
I tried to set QScrollArea background image. it is affecting other widgets like line edit and label too. how to set image only for scroll area background. I added code below.
from PyQt5 import QtGui,QtCore
from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import *
import os,sys
class SDK(QScrollArea):
def __init__(self):
super().__init__()
self.widget = QWidget()
self.setWidget(self.widget)
self.setWidgetResizable(True)
self.setHorizontalScrollBarPolicy(Qt.ScrollBarPolicy.ScrollBarAlwaysOn)
self.setVerticalScrollBarPolicy(Qt.ScrollBarPolicy.ScrollBarAlwaysOn)
GL=QGridLayout(self.widget)
for i in range(10):
L=QLineEdit('text_'+str(i))
GL.addWidget(L,i,0)
LE=QLineEdit()
GL.addWidget(LE,i,1)
stylesheet2="""QScrollArea QWidget {border-image: url("D:/1.jpg") 0 0 0 0 stretch stretch;}"""
if __name__ == '__main__':
app = QApplication(sys.argv)
app.setStyleSheet(stylesheet2)
window=SDK()
window.showMaximized()
sys.exit(app.exec_())
Solution
got answer for my issue, by assigning
self.widget.setObjectName("home")
and assign stylesheet
stylesheet2="""#home , #setting{border-image: url("D:/1.jpg") 0 0 0 0 stretch stretch;}"""
Answered By - Viswa
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.