I'm trying to work through the tutorial : http://www.qgistutorials.com/en/docs/building_a_python_plugin.html to build a plugin in QGIS 3.4.4. and to implement it with PyQt5 (instead of PyQt4 library in the tutorial).
after many trials, research and errors I managed to get to step 24 of the tutorial but the problem is that once I've put the push button with Qt Creator, I've added some code in "__init__" :
def __init__(self, iface):
[...]
#for the ... button to be triggered
self.dlg.lineEdit.clear()
self.dlg.pushButton.clicked.connect(self.select_output_file)
Then, I've added the function "select_output_file" in order to select a file to put in my dialog window :
def select_output_file(self):
#Called when the user presses the ... button
filename,_ = QFileDialog.getSaveFileName(self.dlg, "Select output file ","", '*.txt')
self.dlg.lineEdit.setText(filename)
I've added an underscore ,_ as QFileDialog.getSaveFileName() returns a tuple compared to the PyQt4 version.
After many searches and trials I can't figure out how to make this button work.
initGui()
function and place them inside therun()
function then reload your plugin and try again.