J'ai utilisé la méthode
self.fenetre.setAttribute(QtCore.Qt.WA_DeleteOnClose)
pour détruire les ressources allouées et j'ai eu cette erreur :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
| An error has occurred while executing Python code:
RuntimeError: wrapped C/C++ object of type QLineEdit has been deleted
Traceback (most recent call last):
File "C:/Users/emna/.qgis2/python/plugins\TRANUSInterfaceVariation\TRANUS_Interface_Variation.py", line 192, in run
self.dlg.show()
File "C:/Users/emna/.qgis2/python/plugins\TRANUSInterfaceVariation\TRANUS_Interface_Variation_dialog.py", line 159, in show
self.layers_group_name.setText('Tranus Variation')
RuntimeError: wrapped C/C++ object of type QLineEdit has been deleted
Python version: 2.7.5 (default, May 15 2013, 22:44:16) [MSC v.1500 64 bit (AMD64)]
QGIS version: 2.18.3 Las Palmas, 77b8c3d
Python Path:
C:/OSGEO4~1/apps/qgis/./python/plugins\processing
C:/OSGEO4~1/apps/qgis/./python
C:/Users/emna/.qgis2/python
C:/Users/emna/.qgis2/python/plugins
C:/OSGEO4~1/apps/qgis/./python/plugins
C:\OSGEO4~1\apps\Python27\lib\site-packages\pip-9.0.1-py2.7.egg
C:\OSGEO4~1\bin\python27.zip
C:\OSGEO4~1\apps\Python27\DLLs
C:\OSGEO4~1\apps\Python27\lib
C:\OSGEO4~1\apps\Python27\lib\plat-win
C:\OSGEO4~1\apps\Python27\lib\lib-tk
C:\OSGEO4~1\bin
C:\OSGEO4~1\apps\Python27
C:\OSGEO4~1\apps\Python27\lib\site-packages
C:\OSGEO4~1\apps\Python27\lib\site-packages\jinja2-2.7.2-py2.7.egg
C:\OSGEO4~1\apps\Python27\lib\site-packages\markupsafe-0.23-py2.7-win-amd64.egg
C:\OSGEO4~1\apps\Python27\lib\site-packages\pytz-2012j-py2.7.egg
C:/Users/emna/.qgis2//python
C:\Users\emna\.qgis2\python\plugins\tranus_qgis_plugin |
Pour info, j'intègre mon interface sous forme de plugin dans QGIS, du coup j'aimerais bien initialiser les valeurs de la première fenêtre

Envoyé par
tyrtamos
Bonjour,
Les 2 méthodes sont très différentes:
- "hide" permet de ne pas afficher la fenêtre, mais elle existe toujours et peut être ré-affichée avec "show".
- "close" permet de fermer la fenêtre qui n'existe plus. On peut d'ailleurs aller plus loin:
=> en surchargeant la méthode "closeEvent" pour tester si le contexte ou l'utilisateur permette effectivement la fermeture
=> en demandant au moment du lancement de la fenêtre que les ressources allouées à la fenêtre soient détruites à la fermeture:
self.fenetre.setAttribute(QtCore.Qt.WA_DeleteOnClose)
Partager