QStringList temp = allServices; QString current; for(int i = 0; i < temp.size(); ++i) { current = temp.at(i); if(!current.startsWith(text, Qt::CaseInsensitive)) { QMessageBox msg; msg.setText("Removing " + temp.at(i)); msg.exec(); temp.removeAt(i); } }