-
Notifications
You must be signed in to change notification settings - Fork 23
Description
Discussed in #194
Originally posted by adam-grant-hendry July 8, 2022
When using QtInteractor (Windows 10 with PySide6)
from pyvistaqt import MainWindow, QtInteractor
from qtpy import QtWidgets
class Window(MainWindow):
def __init__(self):
super().__init__()
self.setWindowTitle('Example')
self.layout_ = QtWidgets.QVBoxLayout()
self.container = QtWidgets.QFrame()
self.container.setLayout(self.layout_)
self.setCentralWidget(self.container)
self.plotter = QtInteractor(parent=self.container)
self.layout_.addWidget(self.plotter)
self.plotter.show()
self.signal_close.connect(self.plotter.close)
app = QtWidgets.QApplication([])
window = Window()
window.show()
app.exec_()The error:
QPainter::begin: Paint device returned engine == 0, type: 1
appears every time the screen is updated (even if plotter.show() is placed after window.show().
From the PySide6 QPaintEngine docs, the error is saying Qt thinks I am on X11:
QPaintEngine.X11 == 0QPainEngine.Windows == 1
After debugging in VSCode with the following launch.json so the debugger goes into packages:
{
"configurations": [
{
"name": "Python: Current File",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
"justMyCode": false
}
],
}I found the error happens when rwi.py::QVTKRenderWindowInteractor.paintEngine() is called in response to a Paint event:
def paintEngine(self):
return NoneI also noticed pyvistaqt.rwi::QVTKRenderWindowInteractor.__init__() sets widget attribute
self.setAttribute(WidgetAttribute.WA_PaintOnScreen)From the PySide6 docs, this flag is only supported on X11 and requires returning NULL (None) from paintEngine:
Hence, an alternative is needed for non-X11 systems (Windows, Mac) running PySide for OpenGL to be possible.
