I have a dialog in which a user selects the files that needs, it adds (via QPushButton) in a QListWidget, my problem it's that I need to recover all the files from the QListWidget in a QStringList.
I tried like this, but something is wrong:
self.file = QtCore.QStringList()
archivos = self.file
cuenta = self.ventana.listWidget.count()
for index in range(cuenta):
archivos.append(self.ventana.listWidget.item(index))
I think you're missing .text()
after the item:
self.file = QtCore.QStringList()
archivos = self.file
cuenta = self.ventana.listWidget.count()
for index in range(cuenta):
archivos.append(self.ventana.listWidget.item(index).text())
As I understood, you need to add the selected item text value to a QStringList. Here's how to do it.
QStringList *mList = new QStringList();
QString currItem = ui->listWidget->currentItem()->text();
mList->append(currItem);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.