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 a simple 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")
    dock2 = QtWidgets.QDockWidget("Two")
    dock3 = QtWidgets.QDockWidget("Three")
    dock4 = QtWidgets.QDockWidget("Four")

    label1 = QtWidgets.QLabel("Widget 1")
    label2 = QtWidgets.QLabel("Widget 1")
    label3 = QtWidgets.QLabel("Widget 1")
    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.

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. The issue is also there if QVTKRenderWindowInteractor is set as the central widget of the main window, rather than put in a dock.

There’s no issue with moving or resizing the docks on Ubuntu 18.04 and Windows 10.

Any suggestions for what might be going on would be much appreciated!