It would be better to have a function template for this, along the lines of:

template<typename List>
QString idListToString(const List &ids)
{
...
foreach(const typename List::value_type &id, ids) ...
...
}