当前位置: 首页>>代码示例>>Python>>正文


Python QgsMapLayerComboBox.setCurrentIndex方法代码示例

本文整理汇总了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
开发者ID:wqjzzgci,项目名称:pyqgis-samples,代码行数:31,代码来源:qgis-sample-QgsMapLayerComboBox.py

示例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:
开发者ID:nextgis,项目名称:qgis.connect_points,代码行数:70,代码来源:dialog.py


注:本文中的qgis.gui.QgsMapLayerComboBox.setCurrentIndex方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。