I am creating a plugin in Qgis and I need to enter values to a QTableWidget through the interface, but I cannot find a function that returns them to me.
I do not do it with a LineEdit because I need the number of spaces to fill out equal to those of a listWidget.
try to do it with QTableWidget itemAt but the return is a QTableWidgetItem.
the code is the following:
def Input_shape (self):
filefolder= QFileDialog.getExistingDirectory(self.dlg, "", "/desktop")
filename = glob.glob(filefolder+"/"+"\\*.shp")
self.dlg.comboBox_2.clear()
self.dlg.listWidget.clear()
self.dlg.comboBox_2.addItems([filefolder])
self.dlg.listWidget.addItems(filename)
self.dlg.tableWidget.clear()
self.dlg.tableWidget.setRowCount(len(filename))
self.dlg.tableWidget.setColumnCount(2)
def run(self):
if self.first_start == True:
self.first_start = False
self.dlg = SubsueloDialog()
self.dlg.boton_entrada.clicked.connect(self.Input_shape)
filefolder= self.dlg.comboBox_2.currentText()
filenames = glob.glob(filefolder+"/"+"\\*.shp")
limites= self.dlg.tableWidget.item(1,1)
The interface looks like this:
Best Answer
In following code, you have an example where you can get all values typed in a QTableWidget object by using a function connected to a QPushButton.
After running the code, I got a Dialog similar to yours where I typed arbitrary values for each QTableWidgetItem objects.
After clicking RUN button, print_table_values function printed in Python Console all values as expected.