Joint use of Python, VTK and QTdesigner

related information

VTK

Official document:
VTK 9.2 Documentation
VTK_python on medical image examples (with code)

1. Getting started with VTK_python
2. Getting started with VTK 3D graphics drawing with Python
3. About the settings of vtkActor, vtkRenderer, and vtkRenderWindow in vtk

PySide

1. Use the PySide6 graphical interface framework to make GUI (including the setting method of .ui to .py) 2.
Use PySide6, PyQt6, ui file to py file, and Qt Designer
3. Recommend beautiful Pyqt/Pyside interface templates
4. How to use QScrollBar
5. How to use QSlider (slide bar)

other

1.png to ico file website

question

1. vtk.qt.QVTKRenderWindowInteractor reports an error

vtk.qt.QVTKRenderWindowInteractor corresponds to VTK8.1.2 version, and VTK9.0.1 version will report an error.

solution:

Solution ①: Install a lower version of vtk: pip install vtk==8.0.2
Solution ②: Change vtk.qt.QVTKRenderWindowInteractor to vtkmodules.qt.QVTKRenderWindowInteractor

2. Pyside reports an error

报错内容:
This application failed to start because no Qt platform plugin could be initialized.Reinstalling the application may fix this problem.

insert image description here

Reason: The current python environment lacks libraries under the Qt platform plugin

solution:

Solution ①: Add the Qt platform plugin path in the code (the symptom is not the root cause, it must be added every time)

dirname = os.path.dirname(PySide6.__file__)
plugin_path = os.path.join(dirname, 'plugins', 'platforms')
os.environ['QT_QPA_PLATFORM_PLUGIN_PATH'] = plugin_path

Solution ②: Add system environment variables
insert image description here

Solution ③: rebuild a python virtual environment, and then reinstall PySide6

3. How does Qt Designer manage (Tab new, delete, rename...) QTabWidget tab editor

Solution: https://blog.csdn.net/weixin_43469047/article/details/115606399

Guess you like

Origin blog.csdn.net/Joker00007/article/details/129580300