I am creating a QGIS plugin. I have added a combo box and a push button in the plugin. The issue that I am facing is that I want the ComboBox to either allow selection of layers from the layers loaded on the project or when the user clicks the pushButton it should navigate to the directory and the ComboBox should be filled with the layer selected from the pushButton. Both work individually, but I can't seem to get them working together. I am a beginner in Python, so please let me know if there is anything very obvious that I have missed out on. I am giving my code below. When I run it I get the error -
TypeError: native Qt signal is not callable
def select_input_raster(self):
filename, _filter = QFileDialog.getOpenFileName(
self.dlg, "Select input raster ","", '*.tif')
self.dlg.comboBox.currentTextChanged(filename)
def run(self):
if self.first_start == True:
self.first_start = False
self.dlg = ComboBoxPushButtonDialog()
self.dlg.pushButton.clicked.connect(self.select_input_raster)
layerlist1 = ['<Select a raster layer>']
layers1 = QgsProject.instance().mapLayers().values()
for layer in layers1:
if layer.type() == QgsMapLayer.RasterLayer:
layerlist1.append(layer.name())
#else layerlist1.append(select_input_raster())
#Clear the contents of the comboBox from previous runs
self.dlg.comboBox.clear()
# Populate the comboBox with names of all the loaded raster layers
self.dlg.comboBox.addItems(layerlist1)
# show the dialog
self.dlg.show()
# Run the dialog event loop
result = self.dlg.exec_()