Class: QgsUserProfileManager

class qgis.core.QgsUserProfileManager

Bases: PyQt5.QtCore.QObject

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.

QgsUserProfileManager(rootLocation: str = ‘’, parent: QObject = None) User profile manager used to manage user profiles for the instance of QGIS.

Methods

allProfiles

Returns a list of all found profile names.

childEvent

connectNotify

createUserProfile

Create a user profile given by the name

customEvent

defaultProfileName

Returns the name of the default profile that has been set in .default.

deleteProfile

Deletes a profile from the root profiles folder.

disconnectNotify

getProfile

Returns the profile from the given root profile location.

isNewProfileNotificationEnabled

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

isSignalConnected

lastProfileName

Returns the name of the most recently closed profile.

loadUserProfile

Starts a new instance of QGIS for the given profile.

profileExists

Check if a profile exists.

profileForName

Returns the profile found for a given name.

receivers

resolveProfilesFolder

Resolves the profiles folder for the given path.

rootLocation

Returns the path to the root profiles location.

rootLocationIsSet

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

sender

senderSignalIndex

setActiveUserProfile

Sets the active profile in the manager.

setDefaultFromActive

Set the default profile name from the current active profile.

setDefaultProfileName

Sets the default profile name.

setNewProfileNotificationEnabled

Sets whether the manager should watch for the creation of new user profiles and emit the profilesChanged() signal when this occurs.

setRootLocation

Set the root profile location for the profile manager.

setUserProfileSelectionPolicy

Sets the user profile selection policy.

settings

Returns the settings for the profile manager.

timerEvent

userProfile

The currently active user profile.

userProfileSelectionPolicy

Returns the user profile selection policy.

Signals

profilesChanged

pyqtSignal(*types, name: str = ..., revision: int = ..., arguments: Sequence = ...) -> PYQT_SIGNAL

allProfiles(self) List[str]

Returns a list of all found profile names.

Return type:

List[str]

childEvent(self, QChildEvent)
connectNotify(self, QMetaMethod)
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(self, QEvent)
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(self, QMetaMethod)
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(self, QMetaMethod) bool
lastProfileName(self) str

Returns the name of the most recently closed profile. Empty if it is the first time QGIS is run.

New in version 3.32.

Return type:

str

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

pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

Parameters:
  • name (str = ...) –

  • revision (int = ...) –

  • arguments (Sequence = ...) –

Return type:

PYQT_SIGNAL

receivers(self, PYQT_SIGNAL) int
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(self) QObject
senderSignalIndex(self) int
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.

setUserProfileSelectionPolicy(self, policy: Qgis.UserProfileSelectionPolicy)

Sets the user profile selection policy.

Parameters:

policy (Qgis.UserProfileSelectionPolicy) – The policy to use when selecting a user profile.

New in version 3.32.

settings(self) QSettings

Returns the settings for the profile manager.

New in version 3.32.

Return type:

QSettings

timerEvent(self, QTimerEvent)
userProfile(self) QgsUserProfile

The currently active user profile.

Return type:

QgsUserProfile

Returns:

The currently active user profile.

userProfileSelectionPolicy(self) Qgis.UserProfileSelectionPolicy

Returns the user profile selection policy.

New in version 3.32.

Return type:

Qgis.UserProfileSelectionPolicy