Skip to content

QWidget: Must construct a QApplication before a QWidget #37

@younes1010

Description

@younes1010

Hi,
I'm trying to re-implement the scikit-surgerytutorial01 so I exactly followed all steps indicated in the documentation "https://scikit-surgerytutorial01.readthedocs.io/en/latest/01_VTK_Overlay_App.html" and I created a virtual environment where I installed all requirements with indicated versions on requirements.txt and .yml file. After, I created a file named overlay.py with the following code :

import sys
from PySide2.QtWidgets import QApplication
from sksurgeryutils.common_overlay_apps import OverlayBaseWidget
class OverlayApp(OverlayBaseWidget):
         def update_view(self):
                   _, image = self.video_source.read()
                   self.vtk_overlay_window.set_video_image(image)
                   self.vtk_overlay_window.Render()
if __name__ == '__main__':
         app = QApplication([])
         video_source = 0
         viewer = OverlayApp(video_source)
         model_dir = '../models'
         viewer.add_vtk_models_from_dir(model_dir)
         viewer.show()
         viewer.start()
         sys.exit(app.exec_())

When I execute this code I get :

(python_3.7_venv) younes@younes-ThinkPad-X1-Carbon-3rd:~/python_3.7_venv$ python overlay.py
Warning: Ignoring XDG_SESSION_TYPE=wayland on Gnome. Use QT_QPA_PLATFORM=wayland to run on Wayland anyway.
QWidget: Must construct a QApplication before a QWidget
Aborted (core dumped)

I'd like to know why I get this error: QWidget: Must construct a QApplication before a QWidget and how to deal with this problem.

cheers,
younes

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions