In this case, trimmed only 'title' field of track, but 'artist' field can include white spaces too, so it's also need to be trimmed.
So QString fileName = track->artist().trimmed() + " - " + track->title().trimmed() + ".mp3";