Geographic Information Systems Asked on July 13, 2021
When a layer is on the edit mode and I click on the exit button of the QGIS project, it asks me if I want to save changes that I made (automatically). So, how can I disable it using PyQGIS? I’ve tried QgsProject.instance().setDirty(False)
but it keeps asking if I want to save my changes. The image below shows the message that pops up.
How to automatically discard changes and never prompt the user to save changes?
I saw simillar questions like this one: Is there is a signal in QGIS when a project is about to be closed?
But it was also an open question.
QgsProject.instance().setDirty(False)
works just if you don't modify the project after using it.
If you would like it to be effective until closing QGIS, define a method including that and connect the method to isDirtyChanged
signal.
def set_dirty_false():
QgsProject.instance().setDirty(False)
QgsProject.instance().isDirtyChanged.connect(set_dirty_false)
Answered by Kadir Şahbaz on July 13, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP