For me, using PyQt4.13 on Windows, setting a background-color on the QTableWidget QTableCornerButton
element in the Qt stylesheet has an effect but setting background-image has not. However, you can make the background-color transparent (rgba(0,0,0,0)
) and then you see the background image of the widget shining through. The border should be set again to make it look nice.
Code:
from PyQt4 import QtGui
app = QtGui.QApplication([])
# app.setStyleSheet('QWidget { background-color: #aa8888; } QHeaderView::section { background-color: #88aa88; } QTableWidget QTableCornerButton::section {background-color: #8888aa; }')
# app.setStyleSheet('QWidget { background-image: url(bg.png); } QHeaderView::section { background-image: url(bg.png); } QTableWidget QTableCornerButton::section {background-image: url(bg.png); }')
app.setStyleSheet('QWidget { background-image: url(bg.png); } QHeaderView::section { background-color: rgba(0,0,0,0); } QTableWidget QTableCornerButton::section {background-color: rgba(0,0,0,0); }')
w = QtGui.QTableWidget(2, 2)
w.show()
app.exec_()
Results in (depending on which stylesheet line you use):
Left image: set widget, headerview and tablecornerbutton background color works
Center image: set widget background image, try to set headerview and tablecornerbutton background image but without effect
Right image: set widget background image, set headerview and tablecornerbutton background color to transparent. Borders have to be set again probably.
setCornerWidget()
works for the widget at the crossing of the scrollbars, i.e. bottom-right corner (when scrollbars are visible!). The widget at the crossing of row header and column header (i.e. top left corner) does not appear to be customizable (except that it can be disabled and enabled). – Contractor