[GIS] Clearing Recently used coordinate reference systems using QGIS

coordinate systemqgisqgis-2.10

After using some non usual SRC for demonstration purpose, I wish to clear my "Recently used coordinate reference systems" list for the sake of praticity.

Is it possible?

I am using QGIS 2.10.1.

Best Answer

QGIS 2.x

Yes, you can enter the following code in the Python console to remove all Recently used coordinate reference systems from the user interface:

from PyQt4.QtCore import QSettings

QSettings().remove('UI/recentProjections')
QSettings().remove('UI/recentProjectionsAuthId')

Now I'm not sure why exactly but, for me atleast, using one remove method was not enough. I had to use both (the order does not matter either aslong as both are used).

But it works for me anyway and hopefully for you too!


QGIS 3.x

You could use the following:

from PyQt5.QtCore import QSettings 
QSettings().remove('UI/recentProjections')

Or to import QSettings generically (i.e. from differing major QGIS versions), you could use the following (thanks to @TeddyTedTed):

from qgis.PyQt.QtCore import QSettings
Related Question