Class: QgsNewVectorLayerDialog

Class Hierarchy

Inheritance diagram of qgis.gui.QgsNewVectorLayerDialog

Base classes

QDialog

QWidget

QObject

QPaintDevice

Methods

attributes

Appends the chosen attribute names and types to at

crs

Returns the selected CRS for the new layer.

filename

Returns the name for the new layer

selectedFileEncoding

Returns the file format for storage

selectedFileFormat

Returns the file format for storage

selectedType

Returns the selected geometry type

setCrs

Sets the crs value for the new layer in the dialog.

setFilename

Sets the initial file name to show in the dialog.

Static Methods

execAndCreateLayer

Runs the dialog and creates a layer matching the dialog parameters.

runAndCreateLayer

Runs the dialog and creates a layer matching the dialog parameters.

class qgis.gui.QgsNewVectorLayerDialog(parent: QWidget | None = None, fl: Qt.WindowFlags | Qt.WindowType = QgsGuiUtils.ModalDialogFlags)[source]

Bases: QDialog

attributes(self, at: Iterable[Tuple[str | None, str | None]])[source]

Appends the chosen attribute names and types to at

Parameters:

at (Iterable[Tuple[Optional[str], Optional[str]]])

crs(self) QgsCoordinateReferenceSystem[source]

Returns the selected CRS for the new layer.

See also

setCrs()

Return type:

QgsCoordinateReferenceSystem

static execAndCreateLayer(parent: QWidget | None = None, initialPath: str | None = '', crs: QgsCoordinateReferenceSystem = QgsCoordinateReferenceSystem())[source]

Runs the dialog and creates a layer matching the dialog parameters.

If the initialPath argument is specified, then the dialog will default to the specified filename.

Returns a filename if the dialog was accepted, or an empty string if the dialog was canceled. If the dialog was accepted but an error occurred while creating the file, then the function will return an empty string and errorMessage will contain the error message.

If encoding is specified, it will be set to the encoding of the created file.

Parameters:
  • parent (Optional[QWidget] = None) – parent widget for dialog

  • initialPath (Optional[str] = '') – initial file path to show in dialog

  • crs (QgsCoordinateReferenceSystem = QgsCoordinateReferenceSystem()) -> (str) – default layer CRS to show in dialog

Returns:

  • Newly created file name, or an empty string if user canceled or an error occurred.

  • errorMessage: any error message encountered during layer creation

  • encoding: file encoding of created layer

Added in version 3.4.5.

filename(self) str[source]

Returns the name for the new layer

See also

setFilename()

Return type:

str

static runAndCreateLayer(parent: QWidget | None = None, enc: str | None | None = '', crs: QgsCoordinateReferenceSystem = QgsCoordinateReferenceSystem(), initialPath: str | None = '') str[source]

Runs the dialog and creates a layer matching the dialog parameters.

If the initialPath argument is specified, then the dialog will default to the specified filename.

Return type:

str

Returns:

fileName on success, empty string use aborted, QString() if creation failed

Deprecated since version 3.4.5: Use execAndCreateLayer() instead.

Parameters:
  • parent (Optional[QWidget] = None)

  • enc (Optional[Optional[str]] = '')

  • crs (QgsCoordinateReferenceSystem = QgsCoordinateReferenceSystem())

  • initialPath (Optional[str] = '')

selectedFileEncoding(self) str[source]

Returns the file format for storage

Return type:

str

selectedFileFormat(self) str[source]

Returns the file format for storage

Return type:

str

selectedType(self) Qgis.WkbType[source]

Returns the selected geometry type

Return type:

Qgis.WkbType

setCrs(self, crs: QgsCoordinateReferenceSystem)[source]

Sets the crs value for the new layer in the dialog.

See also

crs()

Parameters:

crs (QgsCoordinateReferenceSystem)

setFilename(self, filename: str | None)[source]

Sets the initial file name to show in the dialog.

See also

filename()

Added in version 3.6.

Parameters:

filename (Optional[str])