Do not apply transparent background in Qt4 (#1403)

* Do not apply transparent background in Qt4

* Tests need to reflect this change too
This commit is contained in:
Ogi Moore 2020-10-17 23:01:16 -07:00 committed by GitHub
parent 9f86eef2b9
commit 2c02d58134
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 7 deletions

View File

@ -131,9 +131,10 @@ class GraphicsView(QtGui.QGraphicsView):
self.clickAccepted = False
# Set a transparent background QPalette!
palette = self.palette()
palette.setColor(QtGui.QPalette.Background, QtCore.Qt.transparent)
self.setPalette(palette)
if QT_LIB in ["PySide2", "PyQt5"]:
palette = self.palette()
palette.setColor(QtGui.QPalette.Background, QtCore.Qt.transparent)
self.setPalette(palette)
def setAntialiasing(self, aa):
"""Enable or disable default antialiasing.

View File

@ -10,8 +10,10 @@ def test_basics_graphics_view():
assert background_role == QtGui.QPalette.Background
palette = view.palette()
assert palette.isBrushSet(QtGui.QPalette.Active, QtGui.QPalette.Background)
assert palette.color(QtGui.QPalette.Background) == QtCore.Qt.transparent
if pg.Qt.QT_LIB in ["PySide2", "PyQt5"]:
assert palette.isBrushSet(QtGui.QPalette.Active, QtGui.QPalette.Background)
assert palette.color(QtGui.QPalette.Background) == QtCore.Qt.transparent
assert view.backgroundBrush().color() == QtGui.QColor(0, 0, 0, 255)
assert view.focusPolicy() == QtCore.Qt.StrongFocus
@ -37,8 +39,10 @@ def test_basics_graphics_view():
view.setBackground("w")
assert view._background == "w"
palette = view.palette()
assert palette.isBrushSet(QtGui.QPalette.Active, QtGui.QPalette.Background)
assert palette.color(QtGui.QPalette.Background) == QtCore.Qt.transparent
if pg.Qt.QT_LIB in ["PySide2", "PyQt5"]:
assert palette.isBrushSet(QtGui.QPalette.Active, QtGui.QPalette.Background)
assert palette.color(QtGui.QPalette.Background) == QtCore.Qt.transparent
assert view.backgroundBrush().color() == QtCore.Qt.white
# Set anti aliasing