Difficulty in resizing/moving QDockWidgets in a PyQt5 app that contains a QVTKRenderWindowInteractor, on MacOS only.
Hi,
I’m building an application using PyQt5 that contains a QVTKRenderWindowInteractor widget within a QDockWidget. On MacOS, adding the QVTKRenderWindowInteractor makes it very difficult to resize or move the docks.
Here’s an example that displays this behaviour:
from PyQt5 import QtWidgets
from PyQt5.QtCore import Qt
from vtkmodules.qt.QVTKRenderWindowInteractor import QVTKRenderWindowInteractor
if __name__ == "__main__":
app = QtWidgets.QApplication([])
main = QtWidgets.QMainWindow()
dock1 = QtWidgets.QDockWidget("One", main)
dock2 = QtWidgets.QDockWidget("Two", main)
dock3 = QtWidgets.QDockWidget("Three", main)
dock4 = QtWidgets.QDockWidget("Four", main)
label1 = QtWidgets.QLabel("Widget 1", dock1)
label2 = QtWidgets.QLabel("Widget 2", dock2)
label3 = QtWidgets.QLabel("Widget 3", dock3)
vtkWidget4 = QVTKRenderWindowInteractor(dock4)
label1.setStyleSheet("background-color:blue")
label2.setStyleSheet("background-color:red")
label3.setStyleSheet("background-color:green")
vtkWidget4.setStyleSheet("background-color:grey")
dock1.setWidget(label1)
dock2.setWidget(label2)
dock3.setWidget(label3)
dock4.setWidget(vtkWidget4)
main.addDockWidget(Qt.LeftDockWidgetArea, dock1)
main.splitDockWidget(dock1, dock2, Qt.Orientation.Vertical)
main.addDockWidget(Qt.RightDockWidgetArea, dock3)
main.splitDockWidget(dock3, dock4, Qt.Orientation.Vertical)
main.setTabPosition(Qt.AllDockWidgetAreas, QtWidgets.QTabWidget.North)
main.showMaximized()
app.exec_()
If in the above example, the QVTKRenderWindowInteractor is removed (or replaced by another QLabel), there is no issue moving or resizing the windows. However, the issue is there if the dock containing the QVTKRenderWindowInteractor is added and then removed from the main window.
I’m using:
macOS 11.6.2
pyqt5 5.15.6
vtk 9.0.3
I’ve also tried PyQt5 versions down to 5.12, as well as PySide2 and PySide6. There’s no issue with moving or resizing the docks on Ubuntu 18.04 and Windows 10, only on macOS.
The issue is also there if QVTKRenderWindowInteractor is set as the central widget of the main window, rather than put in a dock.
Any suggestions for what might be going on would be much appreciated!
P.S. sorry for the cross-post from the forum, but as far as I can tell it seems like a bug rather than something I'm doing wrong - but I would be very happy to stand corrected!