Class: QgsUserProfileManager

class qgis.core.QgsUserProfileManager(rootLocation: str = '', parent: QObject = None)

Bases: PyQt5.QtCore.QObject

User profile manager used to manage user profiles for the instance of QGIS.

User profile manager is used to manager list, and manage user profiles on the users machine.

In QGIS 3 all settings, plugins, etc were moved into a %APPDATA%/profiles folder for each platform. This allows for manage different user profiles per machine vs the single default one that was allowed in the past.

A user profile is all settings and anything that used to be found in .qgis3 in the users home folder.

New in version 3.0.

Parameters
  • rootLocation (str = '') –

  • parent

allProfiles(self) → List[str]

Returns a list of all found profile names.

Return type

List[str]

childEvent()
connectNotify()
createUserProfile(self, name: str) → QgsError

Create a user profile given by the name

Parameters

name (str) –

Return type

QgsError

Returns

A QgsError which report if there was any error creating the user profile.

customEvent()
defaultProfileName(self) → str

Returns the name of the default profile that has been set in .default. First checks profile.ini in \profiles folder Then checks defaultProfile in global settings Finally returns “default” if all else fails

Return type

str

Returns

The name of the default profile.

Note

Setting overrideLocalProfile in global settings will always ignore profiles.ini

deleteProfile(self, name: str) → QgsError

Deletes a profile from the root profiles folder.

Parameters

name (str) – The name of the profile to delete.

Return type

QgsError

Returns

A QgsError with a message if the profile failed to be deleted.

Note

There is no undo on this as it deletes the folder from the machine.

disconnectNotify()
getProfile(self, defaultProfile: str = '', createNew: bool = True, initSettings: bool = True) → QgsUserProfile

Returns the profile from the given root profile location. If no name is given it returns a profile called “default”. By default will create the profile folder if not found. By default will init the user settings.

Parameters
  • defaultProfile (str = '') – The profile name to find. Empty profile name will return “default” for the name.

  • createNew (bool = True) – Create the profile folder if it doesn’t exist.

  • initSettings (bool = True) – if the settings should be initialized

Return type

QgsUserProfile

Returns

The user profile

Note

Returns a new QgsUserProfile. Ownership transferred to caller.

isNewProfileNotificationEnabled(self) → bool

Returns whether the manager is watching for the creation of new user profiles and emitting the profilesChanged() signal when this occurs. By default new profile notification is disabled.

Return type

bool

isSignalConnected()
loadUserProfile(self, name: str)

Starts a new instance of QGIS for the given profile.

Parameters

name (str) – The profile to start QGIS with.

profileExists(self, name: str) → bool

Check if a profile exists.

Return type

bool

Returns

False if the profile can’t be found.

Parameters

name (str) –

profileForName(self, name: str) → QgsUserProfile

Returns the profile found for a given name.

Parameters

name (str) – The name of the profile to return.

Return type

QgsUserProfile

Returns

A QgsUserprofile pointing to the location of the user profile.

profilesChanged

Emitted when the list of profiles is changed.

This signal will only be emitted when isNewProfileNotificationEnabled() is true. By default new profile notification is disabled.

receivers()
resolveProfilesFolder(basePath: str = '') → str

Resolves the profiles folder for the given path. Path will have \profiles appended to the path

Parameters

basePath (str = '') – The base path to resolve the path from to append the \profiles folder to.

Return type

str

Returns

The root path to store user profiles.

rootLocation(self) → str

Returns the path to the root profiles location.

Return type

str

Returns

The root path to the profiles folder.

rootLocationIsSet(self) → bool

Check if the root location has been set for the manager.

Return type

bool

Returns

True if the root location has been set.

sender()
senderSignalIndex()
setActiveUserProfile(self, profile: str)

Sets the active profile in the manager. This can only be set once. Setting this again does nothing.

Parameters

profile (str) – The name of the active profile

setDefaultFromActive(self)

Set the default profile name from the current active profile.

setDefaultProfileName(self, name: str)

Sets the default profile name. The default profile name is used when loading QGIS with no arguments.

Parameters

name (str) – The name of the profile to save.

setNewProfileNotificationEnabled(self, enabled: bool)

Sets whether the manager should watch for the creation of new user profiles and emit the profilesChanged() signal when this occurs. By default new profile notification is disabled.

Before calling this, ensure that the correct root location has been set via calling setRootLocation().

Parameters

enabled (bool) –

setRootLocation(self, rootProfileLocation: str)

Set the root profile location for the profile manager. All profiles are loaded from this location. Will also contain a profiles.ini for holding profile settings.

Parameters

rootProfileLocation (str) – Path to the top level profile folder which contains folders for each profile.

timerEvent()
userProfile(self) → QgsUserProfile

The currently active user profile.

Return type

QgsUserProfile

Returns

The currently active user profile.