【发布时间】:2019-08-11 01:52:49
【问题描述】:
下面的代码创建了一个单独的 QTableView,其中 jpg 图像设置为背景。
我希望此背景图片居中,而不是与左边缘和上边缘对齐。如何将背景图片定位在中心?
from PySide2.QtGui import *
from PySide2.QtWidgets import *
from PySide2.QtCore import *
app = QApplication([])
view = QTableView()
view.resize(1000, 600)
bg_image = 'stackoverflow.jpg'
view.setStyleSheet("background-repeat:no-repeat;background-image:url(%s)" % bg_image)
view.show()
app.exec_()
【问题讨论】:
标签: python qtableview pyside2