Вы можете go просмотреть список и протестировать тип с помощью dynamic_cast
:
// I'm not sure where you want to implement this,
// but it can be in your derived GraphicsScene class.
// Else, just call scene->items() and make a new list
// outside of the scene class.
void CustomScene::foo()
{
QList<QGraphicsItem*> itemList = items();
for (int i = 0; i < itemList.size(); ++i) {
if (auto lineItem{dynamic_cast<QGraphicsLineItem*>(itemList[i])})
// do a specific action or put this in a QList of QGraphicsLiteItem*s
// and return that list instead of void
;
}
}
Я не тестировал этот код, но что-то подобное должно быть возможно.