Class: QgsFavoritesItem

class qgis.core.QgsFavoritesItem(parent: QgsDataItem, name: str, path: str = '')

Bases: QgsDataCollectionItem

Constructor for QgsFavoritesItem. Accepts a path argument specifying the file path associated with the item.

Contains various Favorites directories

New in version 3.0.

addDirectory(self, directory: str, name: str = '')

Adds a new directory to the favorites group.

If name is specified, it will be used as the favorite’s name. Otherwise the name will be set to match directory.

  • directory (str) –

  • name (str = '') –

childEvent(self, QChildEvent)
connectNotify(self, QMetaMethod)
createChildren(self) → object
Return type


customEvent(self, QEvent)
deferredDelete(self) → bool

The item is scheduled to be deleted. E.g. if deleteLater() is called when item is in Populating state (createChildren() running in another thread), the deferredDelete() returns True and item will be deleted once Populating finished. Items with slow reateChildren() (for example network or database based) may check during createChildren() if deferredDelete() returns True and return from createChildren() immediately because result will be useless. *

disconnectNotify(self, QMetaMethod)
homeDirIcon() → QIcon

Shared home directory icon.

New in version 3.4.

iconFavorites() → QIcon

Icon for favorites group

Return type


isSignalConnected(self, QMetaMethod) → bool
openDirIcon() → QIcon

Shared open directory icon.

New in version 3.4.

populate(self, children: object)

populate(self, foreground: bool = False)

receivers(self, PYQT_SIGNAL) → int
refresh(self, children: object)

Refresh the items from a specified list of child items.


removeDirectory(self, item: QgsDirectoryItem)

Removes an existing directory from the favorites group.

See also



item (QgsDirectoryItem) –

renameFavorite(self, path: str, name: str)

Renames the stored favorite with corresponding path a new name.

  • path (str) –

  • name (str) –

sender(self) → QObject
senderSignalIndex(self) → int
sortKey(self) → Any
Return type


timerEvent(self, QTimerEvent)

Will request a repaint of this icon.

New in version 3.0.