Class: QgsNewNameDialog¶
A dialog for prompting users for a new name, for example new layer name dialog.
If existing names are provided, the dialog warns users if an entered name already exists.
Class Hierarchy¶
Base classes¶
A generic dialog with layout and button box. |
|
Methods
Returns |
|
Returns the string used for warning users if a conflicting name exists. |
|
List of names with extensions |
|
Returns the hint string for the dialog (the text shown above the name input box). |
|
Name entered by user. |
|
Returns whether users are permitted to overwrite existing names. |
|
Sets whether users are permitted to leave the widget empty. |
|
Sets the string used for warning users if a conflicting name exists. |
|
Sets the hint string for the dialog (the text shown above the name input box). |
|
Sets whether users are permitted to overwrite existing names. |
|
Sets a regular expression to use for validating user-entered names in the dialog. |
|
Sets whether a completer for existing names should be used in the line edit. |
Static Methods
Test if name or name with at least one extension exists. |
|
Signals
Emitted when the name is changed in the dialog. |
- class qgis.gui.QgsNewNameDialog[source]¶
Bases:
QgsDialog- __init__(source: str | None = '', initial: str | None = '', extensions: Iterable[str | None] = [], existing: Iterable[str | None] = [], cs: Qt.CaseSensitivity = Qt.CaseSensitive, parent: QWidget | None = None, flags: Qt.WindowFlags | Qt.WindowType = QgsGuiUtils.ModalDialogFlags)
New dialog constructor.
- Parameters:
source (Optional[str] = '') – original data source name, e.g. original layer name of the layer to be copied
initial (Optional[str] = '') – initial name
extensions (Iterable[Optional[str]] = []) – base name extensions, e.g. raster base name band extensions or vector layer type extensions
existing (Iterable[Optional[str]] = []) – existing names
cs (Qt.CaseSensitivity = Qt.CaseSensitive) – case sensitivity for new name to existing names comparison
parent (Optional[QWidget] = None) – parent widget
flags (Union[Qt.WindowFlags, Qt.WindowType] = QgsGuiUtils.ModalDialogFlags) – window flags
Note
Earlier versions had a similar constructor but with extra arguments for
regexpwhich were removed in QGIS 3.22 as they relied on the deprecated QRegExp class. UsesetRegularExpression()instead.Added in version 3.22.
- allowEmptyName(self) bool[source]¶
Returns
Trueif the widget can be left empty (no name filled).See also
Added in version 3.14.
- Return type:
bool
- conflictingNameWarning(self) str[source]¶
Returns the string used for warning users if a conflicting name exists.
See also
- Return type:
str
- static exists(name: str | None, extensions: Iterable[str | None], existing: Iterable[str | None], cs: Qt.CaseSensitivity = Qt.CaseSensitive) bool[source]¶
Test if name or name with at least one extension exists.
- Parameters:
name (Optional[str]) – name or base name
extensions (Iterable[Optional[str]]) – base name extensions
existing (Iterable[Optional[str]]) – existing names
cs (Qt.CaseSensitivity = Qt.CaseSensitive) – case sensitivity for new name to existing names comparison
- Return type:
bool
- Returns:
Trueif name exists
- static fullNames(name: str | None, extensions: Iterable[str | None]) List[str][source]¶
- Parameters:
name (Optional[str])
extensions (Iterable[Optional[str]])
- Return type:
List[str]
- highlightText(self, text: str | None) str[source]¶
List of names with extensions
- Parameters:
text (Optional[str])
- Return type:
str
- hintString(self) str[source]¶
Returns the hint string for the dialog (the text shown above the name input box).
See also
- Return type:
str
- static matching(newNames: Iterable[str | None], existingNames: Iterable[str | None], cs: Qt.CaseSensitivity = Qt.CaseSensitive) List[str][source]¶
- Parameters:
newNames (Iterable[Optional[str]])
existingNames (Iterable[Optional[str]])
cs (Qt.CaseSensitivity = Qt.CaseSensitive)
- Return type:
List[str]
- signal newNameChanged[source]¶
Emitted when the name is changed in the dialog.
Added in version 3.2.
- overwriteEnabled(self) bool[source]¶
Returns whether users are permitted to overwrite existing names.
See also
See also
- Return type:
bool
- setAllowEmptyName(self, allowed: bool)[source]¶
Sets whether users are permitted to leave the widget empty. If
True, the dialog will accept an empty name value.See also
Added in version 3.14.
- Parameters:
allowed (bool)
- setConflictingNameWarning(self, string: str | None)[source]¶
Sets the string used for warning users if a conflicting name exists.
- Parameters:
string (Optional[str]) – warning string. If empty a default warning string will be used.
See also
- setHintString(self, hintString: str | None)[source]¶
Sets the hint string for the dialog (the text shown above the name input box).
- Parameters:
hintString (Optional[str]) – hint text
See also
- setOverwriteEnabled(self, enabled: bool)[source]¶
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. IfFalse, then the dialog will not accept names which already exist.See also
- Parameters:
enabled (bool)
- setRegularExpression(self, expression: str | None)[source]¶
Sets a regular
expressionto use for validating user-entered names in the dialog.Added in version 3.22.
- Parameters:
expression (Optional[str])
- setShowExistingNamesCompleter(self, show: bool)[source]¶
Sets whether a completer for existing names should be used in the line edit.
This is not shown by default. If the dialog is expected to be used in a context where overwriting is permitted, consider enabling this so that users can more easily enter an existing name.
See also
Added in version 3.44.
- Parameters:
show (bool)