Class: QgsColorSchemeList

class qgis.gui.QgsColorSchemeList

Bases: PyQt5.QtWidgets.QTreeView

An editable list of color swatches, taken from an associated QgsColorScheme.

New in version 2.5.

QgsColorSchemeList(parent: QWidget = None, scheme: QgsColorScheme = None, context: str = ‘’, baseColor: Union[QColor, Qt.GlobalColor, QGradient] = QColor()) Construct a new color swatch grid.

actionEvent(self, QActionEvent)
addColor(self, color: QColor | Qt.GlobalColor | QGradient, label: str = '', allowDuplicate: bool = False)

Adds a color to the list

  • color (Union[QColor) – color to add

  • label (str = '') – optional label for color

  • allowDuplicate (bool = False) – set to True to allow duplicate colors to be added, ie colors which already exist in the list

changeEvent(self, QEvent)
childEvent(self, QChildEvent)
closeEditor(self, QWidget, QAbstractItemDelegate.EndEditHint)
closeEvent(self, QCloseEvent)

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.

  • name (str = ...) –

  • revision (int = ...) –

  • arguments (Sequence = ...) –

Return type:


columnCountChanged(self, int, int)
columnResized(self, int, int, int)
commitData(self, QWidget)
connectNotify(self, QMetaMethod)
contextMenuEvent(self, QContextMenuEvent)

Copies colors from the list to the clipboard

See also


create(self, window: PyQt5.sip.voidptr = 0, initializeWindow: bool = True, destroyOldWindow: bool = True)
currentChanged(self, QModelIndex, QModelIndex)
customEvent(self, QEvent)
destroy(self, destroyWindow: bool = True, destroySubWindows: bool = True)
dirtyRegionOffset(self) QPoint
disconnectNotify(self, QMetaMethod)
dragEnterEvent(self, QDragEnterEvent)
dragLeaveEvent(self, QDragLeaveEvent)
dragMoveEvent(self, QDragMoveEvent)
drawBranches(self, QPainter, QRect, QModelIndex)
drawFrame(self, QPainter)
drawRow(self, QPainter, QStyleOptionViewItem, QModelIndex)
drawTree(self, QPainter, QRegion)
dropEvent(self, QDropEvent)
dropIndicatorPosition(self) QAbstractItemView.DropIndicatorPosition
edit(self, QModelIndex)
edit(self, QModelIndex, QAbstractItemView.EditTrigger, QEvent) bool
editorDestroyed(self, QObject)
enterEvent(self, QEvent)
event(self, QEvent) bool
eventFilter(self, QObject, QEvent) bool
exportColorsToGpl(self, file: QFile) bool

Export colors to a GPL palette file from the list


file (QFile) – destination file

Return type:


focusInEvent(self, QFocusEvent)
focusNextChild(self) bool
focusNextPrevChild(self, bool) bool
focusOutEvent(self, QFocusEvent)
focusPreviousChild(self) bool
hideEvent(self, QHideEvent)
horizontalOffset(self) int
horizontalScrollbarAction(self, int)
horizontalScrollbarValueChanged(self, int)
importColorsFromGpl(self, file: QFile) bool

Import colors from a GPL palette file to the list


file (QFile) – file to import

Return type:


indexRowSizeHint(self, QModelIndex) int
initPainter(self, QPainter)
initStyleOption(self, QStyleOptionFrame)
inputMethodEvent(self, QInputMethodEvent)
isDirty(self) bool

Returns whether the color scheme list has been modified

Return type:



True if colors have been modified

isIndexHidden(self, QModelIndex) bool
isSignalConnected(self, QMetaMethod) bool
keyPressEvent(self, event: QKeyEvent)

event (QKeyEvent) –

keyReleaseEvent(self, QKeyEvent)
leaveEvent(self, QEvent)
metric(self, QPaintDevice.PaintDeviceMetric) int
mouseDoubleClickEvent(self, QMouseEvent)
mouseMoveEvent(self, QMouseEvent)
mousePressEvent(self, event: QMouseEvent)

event (QMouseEvent) –

mouseReleaseEvent(self, event: QMouseEvent)

event (QMouseEvent) –

moveCursor(self, QAbstractItemView.CursorAction, Union[Qt.KeyboardModifiers, Qt.KeyboardModifier]) QModelIndex
moveEvent(self, QMoveEvent)
nativeEvent(self, Union[QByteArray, bytes, bytearray], PyQt5.sip.voidptr) Tuple[bool, int]
paintEvent(self, QPaintEvent)

Pastes colors from clipboard to the list

See also


receivers(self, PYQT_SIGNAL) int

Removes any selected colors from the list

resizeEvent(self, QResizeEvent)
rowHeight(self, QModelIndex) int
rowsAboutToBeRemoved(self, QModelIndex, int, int)
rowsInserted(self, QModelIndex, int, int)
rowsRemoved(self, QModelIndex, int, int)
saveColorsToScheme(self) bool

Saves the current colors shown in the list back to a color scheme, if supported by the color scheme.


this method is only effective if the color scheme is editable

Return type:


scheme(self) QgsColorScheme

Returns the scheme currently selected in the list.

See also


New in version 3.0.

Return type:


scrollContentsBy(self, int, int)
scrollDirtyRegion(self, int, int)
selectedIndexes(self) List[QModelIndex]
selectionChanged(self, QItemSelection, QItemSelection)
selectionCommand(self, QModelIndex, event: QEvent = None) QItemSelectionModel.SelectionFlags
sender(self) QObject
senderSignalIndex(self) int
setDirtyRegion(self, QRegion)
setScheme(self, scheme: QgsColorScheme, context: str = '', baseColor: QColor | Qt.GlobalColor | QGradient = QColor())

Sets the color scheme to show in the list

  • scheme (QgsColorScheme) – QgsColorScheme for colors to show in the list

  • context (str = '') – context string provided to color scheme

  • baseColor (Union[QColor) – base color for color scheme

See also


setSelection(self, QRect, Union[QItemSelectionModel.SelectionFlags, QItemSelectionModel.SelectionFlag])
setState(self, QAbstractItemView.State)
setViewportMargins(self, int, int, int, int)
setViewportMargins(self, QMargins) None
sharedPainter(self) QPainter
showEvent(self, QShowEvent)

Displays a file picker dialog allowing users to export colors from the list into a file.

New in version 3.0.


Displays a file picker dialog allowing users to import colors into the list from a file.

New in version 3.0.

sizeHintForColumn(self, int) int
startDrag(self, Union[Qt.DropActions, Qt.DropAction])
state(self) QAbstractItemView.State
tabletEvent(self, QTabletEvent)
timerEvent(self, QTimerEvent)
verticalOffset(self) int
verticalScrollbarAction(self, int)
verticalScrollbarValueChanged(self, int)
viewOptions(self) QStyleOptionViewItem
viewportEvent(self, QEvent) bool
viewportMargins(self) QMargins
viewportSizeHint(self) QSize
visualRegionForSelection(self, QItemSelection) QRegion
wheelEvent(self, QWheelEvent)