Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QWidget: Must construct a QApplication before a QWidget #37

Open
younes1010 opened this issue Jun 29, 2024 · 5 comments · May be fixed by #38
Open

QWidget: Must construct a QApplication before a QWidget #37

younes1010 opened this issue Jun 29, 2024 · 5 comments · May be fixed by #38

Comments

@younes1010
Copy link

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

@younes1010
Copy link
Author

When I changed Pyside2 by Pyside6 the ERROR vanished and the program executed but the problem is that there is nothing shown in the window
Screenshot

@thompson318
Copy link
Collaborator

Hello @younes1010, thanks for raising this. Could you please let me know what your operating system is?

@thompson318
Copy link
Collaborator

Ignore the last comment, I just found your full list here:
https://github.com/orgs/SciKit-Surgery/discussions/121

@thompson318
Copy link
Collaborator

We've always had some problems getting windows to open nicely on the Linux variants. It seems to be very sensitive to versions of PySide and VTK, see this related issue. SciKit-Surgery/scikit-surgeryutils#49. I'll have a quick test and see if I can get the tutorial working for me (Ubuntu 22.04.4 LTS).

@younes1010
Copy link
Author

younes1010 commented Jul 2, 2024

Thank you, Mr. thompson318 . The software works well on Windows, but on Linux, it still poses a problem. I think the issue is caused by a mismatch of the X11 (X Window System) version.

mxochicale added a commit that referenced this issue Jul 5, 2024
@mxochicale mxochicale linked a pull request Jul 5, 2024 that will close this issue
thompson318 added a commit that referenced this issue Jul 25, 2024
thompson318 added a commit that referenced this issue Jul 25, 2024
thompson318 added a commit that referenced this issue Jul 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants