Class: QgsNewNameDialog

class qgis.gui.QgsNewNameDialog

Bases: QgsDialog

New name, for example new layer name dialog. If existing names are provided, the dialog warns users if an entered name already exists.

New in version 2.10.

QgsNewNameDialog(source: str = ‘’, initial: str = ‘’, extensions: Iterable[str] = [], existing: Iterable[str] = [], cs: Qt.CaseSensitivity = Qt.CaseSensitive, parent: QWidget = None, flags: Union[Qt.WindowFlags, Qt.WindowType] = QgsGuiUtils.ModalDialogFlags) New dialog constructor.

Parameters:
  • source – original data source name, e.g. original layer name of the layer to be copied

  • initial – initial name

  • extensions – base name extensions, e.g. raster base name band extensions or vector layer type extensions

  • existing – existing names

  • cs – case sensitivity for new name to existing names comparison

  • parent – parent widget

  • flags – window flags

Note

Earlier versions had a similar constructor but with extra arguments for regexp which were removed in QGIS 3.22 as they relied on the deprecated QRegExp class. Use setRegularExpression() instead.

New in version 3.22.:

Methods

actionEvent

allowEmptyName

Returns True if the widget can be left empty (no name filled).

changeEvent

childEvent

closeEvent

conflictingNameWarning

Returns the string used for warning users if a conflicting name exists.

connectNotify

contextMenuEvent

create

customEvent

destroy

disconnectNotify

dragEnterEvent

dragLeaveEvent

dragMoveEvent

dropEvent

enterEvent

event

eventFilter

exists

Test if name or name with at least one extension exists.

focusInEvent

focusNextChild

focusNextPrevChild

focusOutEvent

focusPreviousChild

fullNames

param name:

hideEvent

highlightText

List of names with extensions

hintString

Returns the hint string for the dialog (the text shown above the name input box).

initPainter

inputMethodEvent

isSignalConnected

keyPressEvent

keyReleaseEvent

leaveEvent

matching

param newNames:

metric

mouseDoubleClickEvent

mouseMoveEvent

mousePressEvent

mouseReleaseEvent

moveEvent

name

Name entered by user.

nameChanged

nativeEvent

overwriteEnabled

Returns whether users are permitted to overwrite existing names.

paintEvent

receivers

resizeEvent

sender

senderSignalIndex

setAllowEmptyName

Sets whether users are permitted to leave the widget empty.

setConflictingNameWarning

Sets the string used for warning users if a conflicting name exists.

setHintString

Sets the hint string for the dialog (the text shown above the name input box).

setOverwriteEnabled

Sets whether users are permitted to overwrite existing names.

setRegularExpression

Sets a regular expression to use for validating user-entered names in the dialog.

sharedPainter

showEvent

tabletEvent

timerEvent

updateMicroFocus

wheelEvent

Signals

newNameChanged

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

actionEvent(self, QActionEvent)
allowEmptyName(self) bool

Returns True if the widget can be left empty (no name filled).

New in version 3.14.

Return type:

bool

changeEvent(self, QEvent)
childEvent(self, QChildEvent)
closeEvent(self, QCloseEvent)
conflictingNameWarning(self) str

Returns the string used for warning users if a conflicting name exists.

New in version 2.12.

Return type:

str

connectNotify(self, QMetaMethod)
contextMenuEvent(self, QContextMenuEvent)
create(self, window: PyQt5.sip.voidptr = 0, initializeWindow: bool = True, destroyOldWindow: bool = True)
customEvent(self, QEvent)
destroy(self, destroyWindow: bool = True, destroySubWindows: bool = True)
disconnectNotify(self, QMetaMethod)
dragEnterEvent(self, QDragEnterEvent)
dragLeaveEvent(self, QDragLeaveEvent)
dragMoveEvent(self, QDragMoveEvent)
dropEvent(self, QDropEvent)
enterEvent(self, QEvent)
event(self, QEvent) bool
eventFilter(self, QObject, QEvent) bool
exists(name: str, extensions: Iterable[str], existing: Iterable[str], cs: Qt.CaseSensitivity = Qt.CaseSensitive) bool

Test if name or name with at least one extension exists.

Parameters:
  • name (str) – name or base name

  • extensions (Iterable[str]) – base name extensions

  • existing (Iterable[str]) – existing names

  • cs (Qt.CaseSensitivity = Qt.CaseSensitive) – case sensitivity for new name to existing names comparison

Return type:

bool

Returns:

True if name exists

focusInEvent(self, QFocusEvent)
focusNextChild(self) bool
focusNextPrevChild(self, bool) bool
focusOutEvent(self, QFocusEvent)
focusPreviousChild(self) bool
fullNames(name: str, extensions: Iterable[str]) List[str]
Parameters:
  • name (str) –

  • extensions (Iterable[str]) –

Return type:

List[str]

hideEvent(self, QHideEvent)
highlightText(self, text: str) str

List of names with extensions

Parameters:

text (str) –

Return type:

str

hintString(self) str

Returns the hint string for the dialog (the text shown above the name input box).

See also

setHintString()

New in version 2.12.

Return type:

str

initPainter(self, QPainter)
inputMethodEvent(self, QInputMethodEvent)
isSignalConnected(self, QMetaMethod) bool
keyPressEvent(self, QKeyEvent)
keyReleaseEvent(self, QKeyEvent)
leaveEvent(self, QEvent)
matching(newNames: Iterable[str], existingNames: Iterable[str], cs: Qt.CaseSensitivity = Qt.CaseSensitive) List[str]
Parameters:
  • newNames (Iterable[str]) –

  • existingNames (Iterable[str]) –

  • cs (Qt.CaseSensitivity = Qt.CaseSensitive) –

Return type:

List[str]

metric(self, QPaintDevice.PaintDeviceMetric) int
mouseDoubleClickEvent(self, QMouseEvent)
mouseMoveEvent(self, QMouseEvent)
mousePressEvent(self, QMouseEvent)
mouseReleaseEvent(self, QMouseEvent)
moveEvent(self, QMoveEvent)
name(self) str

Name entered by user.

Return type:

str

Returns:

new name

See also

newNameChanged()

nameChanged(self)
nativeEvent(self, Union[QByteArray, bytes, bytearray], PyQt5.sip.voidptr) Tuple[bool, int]
newNameChanged

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

overwriteEnabled(self) bool

Returns whether users are permitted to overwrite existing names.

New in version 2.12.

Return type:

bool

paintEvent(self, QPaintEvent)
receivers(self, PYQT_SIGNAL) int
resizeEvent(self, QResizeEvent)
sender(self) QObject
senderSignalIndex(self) int
setAllowEmptyName(self, allowed: bool)

Sets whether users are permitted to leave the widget empty. If True, the dialog will accept an empty name value.

See also

allowEmptyName()

New in version 3.14.

Parameters:

allowed (bool) –

setConflictingNameWarning(self, string: str)

Sets the string used for warning users if a conflicting name exists.

Parameters:

string (str) – warning string. If empty a default warning string will be used.

New in version 2.12.

setHintString(self, hintString: str)

Sets the hint string for the dialog (the text shown above the name input box).

Parameters:

hintString (str) – hint text

See also

hintString()

New in version 2.12.

setOverwriteEnabled(self, enabled: bool)

Sets whether users are permitted to overwrite existing names. If True, then the dialog will reflect that the new name will overwrite an existing name. If False, then the dialog will not accept names which already exist.

New in version 2.12.

Parameters:

enabled (bool) –

setRegularExpression(self, expression: str)

Sets a regular expression to use for validating user-entered names in the dialog.

New in version 3.22.

Parameters:

expression (str) –

sharedPainter(self) QPainter
showEvent(self, QShowEvent)
tabletEvent(self, QTabletEvent)
timerEvent(self, QTimerEvent)
updateMicroFocus(self)
wheelEvent(self, QWheelEvent)