我正在为qgis 3编写一个python插件
基本上,当用户点击一个特性时,我会尝试获取它
mapTool.featureIdentified.connect(onFeatureIdentified)
因此,在函数中确定的特性
def onFeatureIdentified(feature):
print("feature selected : "+ str(feature.id()))
已识别的方法功能传递隐式参数
void QgsMapToolIdentifyFeature::featureIdentified ( const QgsFeature & ) void QgsMapToolIdentifyFeature::featureIdentified ( QgsFeatureId )
我的问题是,我想传递一个其他参数的功能(我想关闭我的窗口时,一个功能是确定的) 就像这样:
mapTool.featureIdentified.connect(onFeatureIdentified(window))
def onFeatureIdentified(feature,window):
print("feature selected : "+ str(feature.id()))
window.quit()
这样,window参数就会覆盖本机方法的隐式参数
我该怎么办
有两种方法:
使用lambda函数(归功于acw1668)传递第二个参数
那么
如果你使用class(像我一样):
在类的\uu init\uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu
那么
第一个参数将是self,然后它将传递函数的本机参数
相关问题 更多 >
编程相关推荐