Class: QgsScaleComboBox¶
- class qgis.gui.QgsScaleComboBox¶
Bases:
PyQt5.QtWidgets.QComboBox
A combobox which lets the user select map scale from predefined list and highlights nearest to current scale value
QgsScaleComboBox(parent: QWidget = None) Constructor for QgsScaleComboBox.
Methods
Returns
True
if the combobox can be set to a NULL value.Returns
True
if the combo box is currently set to a "null" value.Returns the minimum scale, or 0 if no minimum scale set.
Returns the selected scale as a double.
Returns the selected scale as a string, e.g.
Sets whether the scale combobox can be set to a NULL value.
Set the minimum allowed
scale
.Sets the combo box to the null value.
Set the selected scale from a double.
Set the selected scale from a
string
, e.g.Helper function to convert a scale
string
to double.Helper function to convert a
scale
double to scale string.Sets the list of predefined
scales
to show in the combobox.Signals
pyqtSignal(*types, name: str = ..., revision: int = ..., arguments: Sequence = ...) -> PYQT_SIGNAL
- actionEvent(self, QActionEvent)¶
- allowNull(self) bool ¶
Returns
True
if the combobox can be set to a NULL value.See also
See also
See also
New in version 3.8.
- Return type
bool
- changeEvent(self, QEvent)¶
- childEvent(self, QChildEvent)¶
- closeEvent(self, QCloseEvent)¶
- 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)¶
- focusInEvent(self, QFocusEvent)¶
- focusNextChild(self) bool ¶
- focusNextPrevChild(self, bool) bool ¶
- focusOutEvent(self, QFocusEvent)¶
- focusPreviousChild(self) bool ¶
- hideEvent(self, QHideEvent)¶
- initPainter(self, QPainter)¶
- initStyleOption(self, QStyleOptionComboBox)¶
- inputMethodEvent(self, QInputMethodEvent)¶
- isNull(self) bool ¶
Returns
True
if the combo box is currently set to a “null” value.See also
See also
New in version 3.8.
- Return type
bool
- isSignalConnected(self, QMetaMethod) bool ¶
- keyPressEvent(self, QKeyEvent)¶
- keyReleaseEvent(self, QKeyEvent)¶
- leaveEvent(self, QEvent)¶
- metric(self, QPaintDevice.PaintDeviceMetric) int ¶
- minScale(self) float ¶
Returns the minimum scale, or 0 if no minimum scale set. The
scale
value indicates the scale denominator, e.g. 1000.0 for a 1:1000 map. Any scale lower than the minimum scale will automatically be converted to the minimum scale. Except for 0 which is always allowed.- Return type
float
- mouseDoubleClickEvent(self, QMouseEvent)¶
- mouseMoveEvent(self, QMouseEvent)¶
- mousePressEvent(self, QMouseEvent)¶
- mouseReleaseEvent(self, QMouseEvent)¶
- moveEvent(self, QMoveEvent)¶
- nativeEvent(self, Union[QByteArray, bytes, bytearray], PyQt5.sip.voidptr) Tuple[bool, int] ¶
- paintEvent(self, QPaintEvent)¶
- receivers(self, PYQT_SIGNAL) int ¶
- resizeEvent(self, QResizeEvent)¶
- scale(self) float ¶
Returns the selected scale as a double. The scale value indicates the scale denominator, e.g. 1000.0 for a 1:1000 map.
See also
- Return type
float
- scaleChanged¶
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
- scaleString(self) str ¶
Returns the selected scale as a string, e.g. “1:150”.
See also
- Return type
str
- sender(self) QObject ¶
- senderSignalIndex(self) int ¶
- setAllowNull(self, allowNull: bool)¶
Sets whether the scale combobox can be set to a NULL value.
See also
See also
See also
New in version 3.8.
- Parameters
allowNull (bool) –
- setMinScale(self, scale: float)¶
Set the minimum allowed
scale
. Set to 0 to disable the minimum scale. Thescale
value indicates the scale denominator, e.g. 1000.0 for a 1:1000 map. Any scale lower than the minimum scale will automatically be converted to the minimum scale. Except for 0 which is always allowed.- Parameters
scale (float) –
- setNull(self)¶
Sets the combo box to the null value.
This only has an effect if
allowNull()
isTrue
.See also
See also
New in version 3.8.
- setScale(self, scale: float)¶
Set the selected scale from a double. The
scale
value indicates the scale denominator, e.g. 1000.0 for a 1:1000 map.See also
- Parameters
scale (float) –
- setScaleString(self, string: str) bool ¶
Set the selected scale from a
string
, e.g. “1:150”.See also
- Parameters
string (str) –
- Return type
bool
- showEvent(self, QShowEvent)¶
- showPopup(self)¶
- tabletEvent(self, QTabletEvent)¶
- timerEvent(self, QTimerEvent)¶
- toDouble(string: str) Tuple[float, bool] ¶
Helper function to convert a scale
string
to double. The returned value indicates the scale denominator, e.g. 1000.0 for a 1:1000 map. If specified,ok
will be set toTrue
if the string was successfully interpreted as a scale.See also
- Parameters
string (str) –
- Return type
Tuple[float, bool]
- toString(scale: float) str ¶
Helper function to convert a
scale
double to scale string. Thescale
value indicates the scale denominator, e.g. 1000.0 for a 1:1000 map.The returned string will be rounded (e.g. 1:1000, not 1:1000.345).
See also
- Parameters
scale (float) –
- Return type
str
- updateMicroFocus(self)¶
- updateScales(self, scales: Iterable[str] = [])¶
Sets the list of predefined
scales
to show in the combobox. List elements are expected to be valid scale strings, such as “1:1000000”.- Parameters
scales (Iterable[str] = []) –
- wheelEvent(self, QWheelEvent)¶