[PySide] How to get more details about what caused a program crash
adrian.herrmann at qt.io
Tue Nov 8 13:07:15 CET 2022
Generally speaking, I would recommend using an IDE like Qt Creator or Visual Studio Code. They are easy to set up for Python coding and would make it easier to identify and debug problems in your (or our!) code.
For your problem in particular, could you elaborate on this part: "There is no error message, it just closes."
Does the graphical window close? Is there any text output on the console window? Could you check the exit code of Python when your program crashed? Since it sounds like you're using Command Prompt, you would do that by running "echo %errorlevel%" directly after Python exited. (I would also recommend using PowerShell instead of Command Prompt, but one step at a time. 🙂)
You're also welcome to send us a minimal code sample that reproduces the error you describe so we can give it a try on our end.
Finally, I'm also curious if there is a reason in particular you're using PySide2 instead of PySide6?
Best regards :),
Software Engineer, Qt for Python
The Qt Company
Erich-Thilo-Str. 10 12489
adrian.herrmann at qt.io
+49 1578 0598682
Geschäftsführer: Mika Pälsi, Juha Varelius, Jouni Lintunen Sitz der Gesellschaft: Berlin, Registergericht: Amtsgericht Charlottenburg, HRB 144331 B
Von: PySide <pyside-bounces at qt-project.org> im Auftrag von henry.wede--- via PySide <pyside at qt-project.org>
Gesendet: Sonntag, 6. November 2022 23:26
An: pyside at qt-project.org
Betreff: [PySide] How to get more details about what caused a program crash
I am creating a program using PySide2 and Python V3.9.0 under Windows 10. There is no fancy IDE involved... just QtDesigner to create the UI files, Notepad++ to do the editing, and a DOS Window to run the program.
When running the program, the user can add items to a QTreeWidget. There are 5 main "branches" and a dialog box lets the user choose which branch to add an item to. I can add one item to each branch without any problems - but when I add a second item to any branch the program crashes. There is no error message, it just closes. It took awhile to figure out what the problem was.
I tried a couple different ways to add the item, so I don't suspect that is the problem.
The method for adding an items looks like this:
def AddAsset(self, NewAsset, BranchName):
'''Add the new asset as a child to the existing branch.
Item = self.Widget.findItems(BranchName, QtCore.Qt.MatchExactly, column=0)
The print statements always make sense... it has 0 children then 1 child. Next time it has 1 child then 2 children then crashes.
Is there a way to get more detailed information about the problem?
Any suggestions of what my next step should be?
Thanks in advance,
More information about the PySide