hi all,
i have filled a QListWidget with instances of my own class cMassnahme which inherits from QListWidgetItem.
Now i want to find all selected items and put their IDs (those are QStrings, i am not talking about their place within the QListWidget) into a QStringList called filterMassnahmen.
The function QListWidget::selectedItems() returns QListWidgetItems, so if i don't use it differently i won't be able to access my method getID() as this is not a method of QListWidgetItem. Therefore i tried
QList<cMassnahme *> items = listMassnahmen->selectedItems ();
for (int i = 0; i < items.size(); ++i) {
filterMassnahmen << items.at(i)->getID();
}
QList<cMassnahme *> items = listMassnahmen->selectedItems ();
for (int i = 0; i < items.size(); ++i) {
filterMassnahmen << items.at(i)->getID();
}
To copy to clipboard, switch view to plain text mode
which gives me the message:
error: conversion from `QList<QListWidgetItem*>' to non-scalar type `QList<cMassnahme*>' requested
error: conversion from `QList<QListWidgetItem*>' to non-scalar type `QList<cMassnahme*>' requested
To copy to clipboard, switch view to plain text mode
how else could i solve that? even if i tried to reimplement selectedItems() i would have to access QListWidgetItem::selectedItems() in there and still get to the same problem.
Bookmarks