Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the texts of all items from QListWidget in Qt?

Tags:

qt

How can I get the texts of all the widgets in a QListWidget as a QList<QString>?

I can get the list of widget items like this:

QList<QListWidgetItem *> items =
      ui->listWidget->findItems(QString("*"), Qt::MatchWrap | Qt::MatchWildcard);

But that's not exactly what I want, I'd like the list of the widget text() properties.

like image 921
Bokambo Avatar asked Jun 09 '11 05:06

Bokambo


1 Answers

There is no built-in function for that, you'll need to do it manually.

QList<QString> texts;
foreach(QListWidgetItem *item, items)
  texts.append(item->text());

Or something like that.

like image 132
Mat Avatar answered Oct 09 '22 10:10

Mat