本文整理汇总了Python中qgis.gui.QgsMapLayerComboBox.setCurrentIndex方法的典型用法代码示例。如果您正苦于以下问题:Python QgsMapLayerComboBox.setCurrentIndex方法的具体用法?Python QgsMapLayerComboBox.setCurrentIndex怎么用?Python QgsMapLayerComboBox.setCurrentIndex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qgis.gui.QgsMapLayerComboBox
的用法示例。
在下文中一共展示了QgsMapLayerComboBox.setCurrentIndex方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: QDialog
# 需要导入模块: from qgis.gui import QgsMapLayerComboBox [as 别名]
# 或者: from qgis.gui.QgsMapLayerComboBox import setCurrentIndex [as 别名]
# coding: utf-8
from PyQt4.QtGui import QDialog, QFormLayout
from qgis.gui import QgsFieldComboBox, QgsMapLayerComboBox
# Create dialog
new_dialog = QDialog()
# Add combobox for layer and field
map_layer_combo_box = QgsMapLayerComboBox()
map_layer_combo_box.setCurrentIndex(-1)
field_combo_box = QgsFieldComboBox()
# Create a form layout and add the two combobox
layout = QFormLayout()
layout.addWidget(map_layer_combo_box)
layout.addWidget(field_combo_box)
# Add signal event
map_layer_combo_box.layerChanged.connect(field_combo_box.setLayer) # setLayer is a native slot function
def on_field_changed(fieldName):
print(fieldName)
print("Layer field changed")
field_combo_box.fieldChanged.connect(on_field_changed)
new_dialog.setLayout(layout)
new_dialog.show() # To see possibility of this component, you need at least a layer opened
示例2: Dialog
# 需要导入模块: from qgis.gui import QgsMapLayerComboBox [as 别名]
# 或者: from qgis.gui.QgsMapLayerComboBox import setCurrentIndex [as 别名]
#.........这里部分代码省略.........
self.__mainLayout.addWidget(self.__bbox)
self.fillControls(
curPointsLayerFrom,
curPointsLayerTo,
curFNIdFrom,
curFNLink,
curFNIdTo,
curResultLayerName
)
def fillControls(
self,
curPointsLayerFrom,
curPointsLayerTo,
curFNIdFrom,
curFNLink,
curFNIdTo,
curResultLayerName
):
QgisPlugin().plPrint("curPointsLayerFrom: " + curPointsLayerFrom)
QgisPlugin().plPrint("curPointsLayerTo: " + curPointsLayerTo)
QgisPlugin().plPrint("curFNIdFrom: " + curPointsLayerFrom)
QgisPlugin().plPrint("curFNLink: " + curFNIdFrom)
QgisPlugin().plPrint("curPointsLayerFrom: " + curFNLink)
QgisPlugin().plPrint("curFNIdTo: " + curFNIdTo)
QgisPlugin().plPrint("curResultLayerName: " + curResultLayerName)
layerFrom = self.getQGISLayer(curPointsLayerFrom)
layerTo = self.getQGISLayer(curPointsLayerTo)
layerResult = self.getQGISLayer(curResultLayerName, True)
if layerFrom is None:
self.pointsLayerFrom.setCurrentIndex(-1)
self.pointsLayerFrom.setEditText(curPointsLayerFrom)
else:
self.pointsLayerFrom.setLayer(layerFrom)
if layerTo is None:
self.pointsLayerTo.setCurrentIndex(-1)
self.pointsLayerTo.setEditText(curPointsLayerTo)
else:
self.pointsLayerTo.setLayer(layerTo)
if layerResult is None:
self.linesLayer.setCurrentIndex(-1)
self.linesLayer.setEditText(curResultLayerName)
else:
self.linesLayer.setLayer(layerResult)
# self.fnIdFrom.clear()
# self.fnLink.clear()
# self.fnIdTo.clear()
# self.fnIdFrom.setField(curFNIdFrom)
self.fnIdFrom.setCurrentIndex(-1)
self.fnIdFrom.setEditText(curFNIdFrom)
# self.fnLink.setField(curFNLink)
self.fnLink.setCurrentIndex(-1)
self.fnLink.setEditText(curFNLink)
# self.fnIdTo.setField(curFNIdTo)
self.fnIdTo.setCurrentIndex(-1)
self.fnIdTo.setEditText(curFNIdTo)
def getQGISLayer(self, layerName, silent=False):
if layerName is None: