Skip to content

Drawing errors when application uses mix of native and alien widgets #819

@RubendeBruin

Description

@RubendeBruin

I'm encountering drawing errors on the docking system when running my application. My application uses vtk for 3d opengl visuals.
The cause seems to boil down to calling wid = self.winId() in the main widget (in my case QVTKRenderWindowInteractor).

The example below reproduces this issue on a dummy widget.

explorer_ccHB2uBT4F.mp4

Reproduce

import PySide6QtAds
from PySide6QtAds import CDockManager, CDockWidget

from PySide6.QtWidgets import (
    QApplication,
    QLabel,
    QMainWindow,
    QVBoxLayout,
    QWidget,
)

# This class mimics the QVTKRenderWindowInteractor class from vtkmodules.qt.QVTKRenderWindowInteractor

class DummyOpenGLWidget(QWidget):
    def __init__(self, parent=None):
        super().__init__(parent)
        wid = self.winId()    # <---- this line triggers the error; needed for functionality

if __name__ == "__main__":
    app = QApplication()
    mw = QMainWindow()

    dock_manager = PySide6QtAds.CDockManager(mw)

    # create the central widget dock
    main_widget = QWidget()
    
    # setup a vtk widget in the central dock and display a cube in it
    main_layout = QVBoxLayout(main_widget)
    vtk_widget = DummyOpenGLWidget(main_widget)

    main_layout.addWidget(vtk_widget)

    central_dock = PySide6QtAds.CDockWidget(dock_manager, "Central Dock")
    central_dock.setWidget(main_widget)
    central_dock_area = dock_manager.setCentralWidget(central_dock)
    
    d = PySide6QtAds.CDockWidget(dock_manager, "Dock")
    lbl = QLabel(f"Draw artifacts when resizing while undocked")
    d.setWidget(lbl)
    
    dock_manager.addDockWidget(PySide6QtAds.DockWidgetArea.LeftDockWidgetArea, d)

    mw.show()

    app.exec()

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions